alperiox

extracting related items

Oct 20th, 2022
1,350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. # extract the related items carousel's first page
  2. carousel = self.product_page.find("div", {"class": "a-carousel-viewport"})
  3. related_items = carousel.find_all("li")
  4.  
  5. related_item_asins = [item.find("div")['data-asin'] for item in related_items]
  6. # of course, we need to get item links
  7. related_item_links = []
  8. for asin in related_item_asins:
  9.     link = "www.amazon.com/dp/" + asin
  10.     related_item_links.append(link)
Advertisement
Add Comment
Please, Sign In to add comment