Get Image URL from the Web page using Java Script

Hi,
I am trying to fetch Image URLs from

https://www.weibo.com/login.php?category=1760

See sample image highlighted in screenshot below

These images are contained in the HTML code like below

div class=“pic W_piccut_v”<
img >src<=“https://wx3.sinaimg.cn/crop.0.0.1080.804.240/69226ed0ly4gf68x3il7dj20u00mcdhp.jpg” alt=“”
/div

Please suggest how JS can be created and added to get this URL.

Thanks

@ankswe
In general image url can be retrieved with get Attribute activity and src Attribute

for retrieving the images following can be used:

  • find children
  • data scrapping with customized extract configuration on src attribute
1 Like

As suggested earlier, “src” is not returned using Get Attribute, and with Find Children, I am not able to see any UiElement. Can you try this with website suggest sample code.

@ankswe
have a look here:
grafik

clicking the configurator pointed to div. But manually adoption to following is bringing urls as shown above:

<extract>
	<column exact="1" name="Column1" attr="src">
		<webctrl tag="div" class="UG_list_b"/>
		<webctrl tag="div" class="pic W_piccut_v" idx="1"/>
		<webctrl tag="img" idx="1" />
	</column>
</extract>

the important changes are the added
<webctrl tag="img" idx="1" /> and the attr change from text to src

5 Likes

Thanks, this is working. But few questions to enhance my understanding, please confirm on below

  1. Please confirm whether we are adding "webctrl tag=“img” idx=“1” " because we want to the last level data from the img tag, right ?

  2. Since the attribute that contains value in “src” so we changed it to “src” instead of “Text”

But is “Text” default attr, because it was not present in the original html.

Thanks again for your help and it is a new learning for me.

Regards

@ankswe
src is an attribute from html element of tag img
so we need to point the selector to this element. Sometimes indicate item needs some post work as in this situation

Yes default is the text attribute used for the retival. Other attributes are usefull as well: href for links, src for image urls, class for reacting on formats …

Thanks for your explanation. Really appreciate your help.

Regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.