【发布时间】:2021-05-11 11:44:10
【问题描述】:
试图在此页面上获取轮胎的详细信息。 https://eurawheels.com/fr/catalogue/INFINY-INDIVIDUAL 。每个轮胎都有不同的FINITIONS。每个FINITIONS的价格和其他细节都不同。我想单击每个 FINITION 类型。问题是在单击 FINITION 类型时,链接会过时,并且您无法刷新页面,如果这样做会将您带回到起始页面。那么,如何在不刷新页面的情况下避免过时元素错误?
count_added = False
buttons_div = driver.find_elements_by_xpath('//div[@class="btn-group"]')
fin_buttons = buttons_div[2].find_elements_by_xpath('.//button')
fin_count = len(fin_buttons)
if fin_count > 2:
for z in range(fin_count):
if not count_added:
z = z + 2 #Avoid clicking the Title
count_added = True
fin_buttons[z].click()
finition = fin_buttons[z].text
time.sleep(2)
driver.refresh() #Cannot do this. Will take to a different page
【问题讨论】:
标签: python selenium web-scraping