I would make an endless while True loop and break it once there is TimeoutException thrown - this would mean there are no pages to go left:wait = WebDriverWait(driver, 10)while True: # grab the data # click next link try: element = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'reviews_pagination_link_nav'))) element.click() except TimeoutException: break要执行此操作,您需要确保在单击最后一页后,带有class="reviews_pagination_link_nav"的元素不在页面上或不可单击.For this to work, you need to make sure that once you hit the last page, the element with class="reviews_pagination_link_nav" is not on the page or is not clickable. 这篇关于如何使Selenium单击“下一步",然后单击“确定".按钮,直到不再可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-30 08:23