SelectorElementClick to open full image

I am trying to include the full image in the scrape, which is loaded when clicking a button.

Url: https://www.reddit.com/user/<username>/upvoted (example: username = endless_thread)

Sitemap:
{"_id":"reddit_upvoted","startUrl":["https://www.reddit.com/user/endless_thread/upvoted"],"selectors":[{"id":"upvotes","type":"SelectorText","selector":"div.score.likes","parentSelectors":["item"],"multiple":false,"regex":"","delay":0},{"id":"item","type":"SelectorElement","selector":"div.thing","parentSelectors":["_root"],"multiple":true,"delay":0},{"id":"author","type":"SelectorText","selector":"a.author","parentSelectors":["item"],"multiple":false,"regex":"","delay":0},{"id":"sub","type":"SelectorText","selector":"a.subreddit","parentSelectors":["item"],"multiple":false,"regex":"","delay":0},{"id":"title","type":"SelectorText","selector":"a.title","parentSelectors":["item"],"multiple":false,"regex":"","delay":0},{"id":"url","type":"SelectorLink","selector":"a.title","parentSelectors":["item"],"multiple":false,"delay":0},{"id":"preview","type":"SelectorElementClick","selector":"img.preview","parentSelectors":["item"],"multiple":true,"delay":"200","clickElementSelector":"div.expando-button.video","clickType":"clickOnce","discardInitialElements":true,"clickElementUniquenessType":"uniqueHTML"},{"id":"img_full","type":"SelectorImage","selector":"img.preview","parentSelectors":["preview"],"multiple":false,"delay":"500"}]}

I don't think you can download the pic but you can get the url of the pic. You just need to use the Selector image with class IMG and not img.preview

This should get you there.

Now there is another tool where you can plug the results from this into and it will download the actual pics.

{"_id":"reddit_upvoted","startUrl":["https://www.reddit.com/user/endless_thread/upvoted"],"selectors":[{"id":"upvotes","type":"SelectorText","selector":"div.score.likes","parentSelectors":["item"],"multiple":false,"regex":"","delay":0},{"id":"item","type":"SelectorElement","selector":"div.thing","parentSelectors":["_root"],"multiple":true,"delay":0},{"id":"author","type":"SelectorText","selector":"a.author","parentSelectors":["item"],"multiple":false,"regex":"","delay":0},{"id":"sub","type":"SelectorText","selector":"a.subreddit","parentSelectors":["item"],"multiple":false,"regex":"","delay":0},{"id":"title","type":"SelectorText","selector":"a.title","parentSelectors":["item"],"multiple":false,"regex":"","delay":0},{"id":"url","type":"SelectorLink","selector":"a.title","parentSelectors":["item"],"multiple":false,"delay":0},{"id":"img","type":"SelectorImage","selector":"img","parentSelectors":["item"],"multiple":false,"delay":0}]}

This one takes the small version.

What I am trying to do is to click the "play" button (see screencast above), which dynamically loads up a preview of the bigger version of thumbnail. This is what I am trying to extract (the src attribute of it). The clickElementSelector opens up the bigger image but fails to extract the URL of it.

So if the click selector open it up, you need a child selector to scrape he image. Let me try to figure out how to get the link.

1 Like

Gotcha. It works, thanks!