I have 5 or 6 products under an anchor tag and in the same anchor tag, there is product name and price with distinct div. What I am trying to do compare the price of all products and click the link with the highest price.
My approach was:
product = driver.find_elements_by_xpath('//div[@class="slug__Grid-vcgsbx-0 hPFNJV pb-24 my-4 md:pb-4"]')
for individual in product:
productlink = individual.find_elements_by_tag_name("a")
for link in productlink:
data['link']= link.get_attribute('href')
print(link.get_attribute('href'))
name = link.find_elements_by_xpath('//p[@class="Card___StyledP4-sc-1629dl9-4 fWEsJX text-sm text-gray-800"]')
price = link.find_element_by_xpath('//p[@class="Card___StyledP2-sc-1629dl9-1 cFzjHk"]')
for singlename in name:
data["name"]=singlename.text
print(singlename.text)
for singleprice in price:
data["price"]=singleprice.text
I just scraped the value from the page but couldn't make logic on how should I do that. I have added a page link and an image (in case if you don't want to click the link you can see the photo).
Page Link:: problem page link
Images:: product frontend page
Image2:: product page inspect mode