Python Forum
Getting a URL from Amazon using requests-html, or beautifulsoup
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting a URL from Amazon using requests-html, or beautifulsoup
#1
I'm new to scraping and am working on a scraper, I'm trying to figure out how to pull a URL from the src of this line of HTML:

<img alt="Bube Dame König Gras [Import allemand]" src="https://m.media-amazon.com/images/I/81f+DecFsrL._SY445_.jpg" data-old-hires="https://m.media-amazon.com/images/I/81f+DecFsrL._SL1500_.jpg" onload="markFeatureRenderForImageBlock(); this.onload='';setCSMReq('af');if(typeof addlongPoleTag === 'function'){ addlongPoleTag('af','desktop-image-atf-marker');};setCSMReq('cf')" class="a-dynamic-image a-stretch-vertical" id="landingImage" data-a-dynamic-image="{&quot;https://m.media-amazon.com/images/I/81f+DecFsrL._SY679_.jpg&quot;:[679,480],&quot;https://m.media-amazon.com/images/I/81f+DecFsrL._SY550_.jpg&quot;:[550,389],&quot;https://m.media-amazon.com/images/I/81f+DecFsrL._SY445_.jpg&quot;:[445,315],&quot;https://m.media-amazon.com/images/I/81f+DecFsrL._SY500_.jpg&quot;:[500,353],&quot;https://m.media-amazon.com/images/I/81f+DecFsrL._SY606_.jpg&quot;:[606,428]}" style="max-width: 160.471px; max-height: 227px;"> </div>

I haven't had any luck pointing to this line to get the src. I'd settle for copying the html, making it text and finding it that way, it might actually be better that way. I'm using request-html, though Beautifulsoup might do this better. Any help would be appreciated!
Reply
#2
Like this.
>>> img = soup.find('img')
>>> img.get('src')
'https://m.media-amazon.com/images/I/81f+DecFsrL._SY445_.jpg'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Requests_HTML not getting all data on Amazon aaander 1 1,339 Nov-19-2022, 02:09 AM
Last Post: aaander
  requests-html + Beautifulsoup klaarnou 0 2,447 Mar-21-2022, 05:31 PM
Last Post: klaarnou
  POST requests - different requests return the same response Default_001 3 1,953 Mar-10-2022, 11:26 PM
Last Post: Default_001
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,652 Mar-14-2021, 12:23 PM
Last Post: rfeyer
Smile Extracting the Address tag from multiple HTML files using BeautifulSoup Dredd 8 4,955 Jan-25-2021, 12:16 PM
Last Post: Dredd
  Can't open Amazon page Pavel_47 3 3,229 Oct-21-2020, 09:13 AM
Last Post: Aspire2Inspire
  New in Python Amazon Scraping brian1425 1 2,030 Jul-10-2020, 01:00 PM
Last Post: snippsat
  Requests-HTML vs Beautiful Soup - How to Choose? robin73 0 3,829 Jun-23-2020, 02:53 PM
Last Post: robin73
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,377 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  Amazon AWS - how to install the library chatterbot wpaiva 9 3,894 Feb-01-2020, 08:18 AM
Last Post: brighteningeyes

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020