def _find_next_page_element(self):
"""Finds the element that locates the next page for any search engine.
Returns:
The element that needs to be clicked to get to the next page or a boolean value to
indicate an error condition.
"""
if self.search_type == 'normal':
selector = self.next_page_selectors[self.search_engine_name]
try:
# wait until the next page link is clickable
WebDriverWait(self.webdriver, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR, selector)))
except (WebDriverException, TimeoutException):
self._save_debug_screenshot()
# raise Exception('{}: Cannot locate next page element: {}'.format(self.name, str(e)))
try:
return self.webdriver.find_element_by_css_selector(selector)
except Exception:
logger.error('failed find_element_by_css_selector, sleep 30 sec')
time.sleep(30)
pass
elif self.search_type == 'image':
self.page_down()
if self.search_engine_name == 'google':
return self.webdriver.find_element_by_css_selector('input._kvc')
else:
return True
评论列表
文章目录