【发布时间】:2021-06-14 06:50:53
【问题描述】:
def addtocart():
#driver.get("https://www.mrporter.com/en-gb/mens/product/nike/shoes/low-top-sneakers/space-hippie-04-recycled-stretch-knit-sneakers/19971654707345242")
driver.get("https://www.mrporter.com/en-gb/mens/product/nike/shoes/low-top-sneakers/plus-sacai-blazer-low-colour-block-leather-sneakers/10163292708776845?ntfyeu=jo5suw")
while driver.find_element_by_xpath("/html/body/main/div/div[2]/div/div[1]/div[2]/div[8]/div[2]").is_displayed():
time.sleep(2)
driver.refresh()
print("Item out of stock , waiting for product")
else:
driver.find_element_by_xpath("/html/body/main/div/div[2]/div/div[1]/div[2]/div[6]/div/div/div").click()
addtocart()
在我的代码中,如果页面上显示“对不起,此商品已售罄。请将其添加到您的愿望清单,这样您就不会错过如果它再次可用”我希望它保持刷新直到它成为库存(评论的链接有一个例子)。当产品有库存时(该消息不再显示在页面上)我希望它跳到其他地方。
由于某种原因,它没有跳到其他地方
【问题讨论】:
标签: python selenium selenium-chromedriver