我正在使用下面的代码点击“显示更多评论”按钮,但不起作用。
代码:
link= 'https://www.capterra.com/p/5938/Oracle-Database/'
driver.get(link)
while True:
try:
driver.find_element_by_partial_link_text('Show more reviews').click()
# Wait till the container of the recipes gets loaded
# after load more is clicked.
time.sleep(5)
except (NoSuchElementException, WebDriverException) as e:
break
page_source = driver.page_source
#BEAUTIFUL SOUP OPTION
soup = BeautifulSoup(page_source,"lxml")错误语句
NoSuchElementException: no such element: Unable to locate element: {"method":"partial link text","selector":"Show more reviews"}
(Session info: headless chrome=76.0.3809.132)提前谢谢。
发布于 2019-09-13 16:47:34
找到了答案。
driver.find_element_by_xpath('//button[normalize-space()="Show more reviews"]').click()
参考资料- https://stackoverflow.com/a/48673343/6486100感谢@Andersson
https://stackoverflow.com/questions/57920074
复制相似问题