Skip to main content

Has anyone successfully used Web clipper + CSS Selector + Regex?

  • May 1, 2020
  • 6 replies
  • 54 views

Dean_Arnold
Forum|alt.badge.img+11

I’m trying to extract Amazon images from within a script element on this page:

Mens Polyester Sweater Pullover Hoodie Fleece Sweatshirt for Extinction...

Suitable For Daily Wear/Lounging/hang-out/party/Street Wear/Couple Wear/Sisters Brothers Wear,great Gift For Family And Friends.

Here is the portion of the script including the image URLs:
“large”:“https://images-na.ssl-images-amazon.com/images/I/41TtSJe5lcL.AC.jpg”,“main”:{“https://images-na.ssl-images-amazon.com/images/I/61HuEOCursL.AC_UX342.jpg”:[342,342],“https://images-na.ssl-images-amazon.com/images/I/61HuEOCursL.AC_UX385.jpg”:[385,385],“https://images-na.ssl-images-amazon.com/images/I/61HuEOCursL.AC_UX425.jpg”:[425,425],“https://images-na.ssl-images-amazon.com/images/I/61HuEOCursL.AC_UX466.jpg”:[466,466],“https://images-na.ssl-images-amazon.com/images/I/61HuEOCursL.AC_UX522.jpg”:[522,522],“https://images-na.ssl-images-amazon.com/images/I/61HuEOCursL.AC_UX569.jpg”:[569,569],“https://images-na.ssl-images-amazon.com/images/I/61HuEOCursL.AC_UX679.jpg”:[679,679]},“variant”:“MAIN”,“lowRes”:null},{“hiRes”:“https://images-na.ssl-images-amazon.com/images/I/51FZl9OYafL.AC_UL1200.jpg”,“thumb”:“https://images-na.ssl-images-amazon.com/images/I/31wH6HDKdZL.AC_SR38,50.jpg”,“large”:“https://images-na.ssl-images-amazon.com/images/I/31wH6HDKdZL.AC.jpg”,“main”

Here are the two image URLs I need:
https://images-na.ssl-images-amazon.com/images/I/41TtSJe5lcL.AC.jpg
https://images-na.ssl-images-amazon.com/images/I/31wH6HDKdZL.AC.jpg

Any suggestions how to grab the image URLs I need for my Airtable image field?

Many thanks

6 replies

Forum|alt.badge.img+19
  • Inspiring
  • 323 replies
  • May 1, 2020

There are so many ways to solve this problem but the way I’d do it is:

Just grab the keys from the object using Object.values(myObject); loop through the returned array and pull out whichever ones you need.


Dean_Arnold
Forum|alt.badge.img+11
  • Author
  • Inspiring
  • 44 replies
  • May 1, 2020

There are so many ways to solve this problem but the way I’d do it is:

Just grab the keys from the object using Object.values(myObject); loop through the returned array and pull out whichever ones you need.


Thanks @andywingrave !

I’m not a developer and I don’t understand what you’re saying.

In my Web Clipper (screenshot below), is there a CSS Selector I can use to grab the two image URLs?


Forum|alt.badge.img+19
  • Inspiring
  • 323 replies
  • May 1, 2020

Thanks @andywingrave !

I’m not a developer and I don’t understand what you’re saying.

In my Web Clipper (screenshot below), is there a CSS Selector I can use to grab the two image URLs?


Ok - Your links aren’t working for me. can you send me a screenshot of the images you want to pull from Amazon please?


Dean_Arnold
Forum|alt.badge.img+11
  • Author
  • Inspiring
  • 44 replies
  • May 1, 2020

Sure

They are the main images for the product. When you click the thumbs to the left they display. The current product and page in question only has two thumbnails and corresponding large images. Other products/pages have as many as 8 images.


Forum|alt.badge.img+19
  • Inspiring
  • 323 replies
  • May 1, 2020

Try using this for the big image:

.a-dynamic-image

If that works - Great! The side images I think might be trickier though. I can’t take a look at this until this weekend sadly - But I hope that points you in the right direction :confused:


Dean_Arnold
Forum|alt.badge.img+11
  • Author
  • Inspiring
  • 44 replies
  • May 1, 2020

Works! Classy :winking_face:

Grabs the first image anyway. Not the second.