мой код:
Код: Выделить всё
driver.get('https://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=sonicare+toothbrush')
for page in range(1, last_page_number + 1):
driver.implicitly_wait(10)
bottom_bar = driver.find_element_by_class_name('pagnCur')
driver.execute_script("arguments[0].scrollIntoView(true);", bottom_bar)
current_page_number = int(driver.find_element_by_class_name('pagnCur').text)
if page == current_page_number:
next_page = driver.find_element_by_xpath('//div[@id="pagn"]/span[@class="pagnLink"]/a[text()="{0}"]'.format(current_page_number + 1))
next_page.click()
print('page #', page, ': going to next page')
else:
print('page #: ', page, 'error')
< /code>
Я посмотрел на этот вопрос, и я предполагаю, что аналогичное исправление можно применить, но я не уверен, как найти что -то на странице, которое исчезает. Кроме того, основываясь на том, как быстро возникают операторы печати, я вижу, что неявный_вейт (10)
Код: Выделить всё
StaleElementReferenceException: Message: The element reference of is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed
Код: Выделить всё
ValueError: invalid literal for int() with base 10: ''
Подробнее здесь: https://stackoverflow.com/questions/536 ... ith-python