点击网页中的"显示更多交易"与Python Selenium



我使用以下代码单击"显示更多评论"按钮,但不起作用。

法典:

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)

提前谢谢。

找到了答案。

driver.find_element_by_xpath('//button[normalize-space()="Show more reviews"]').click()

参考资料 - https://stackoverflow.com/a/48673343/6486100 谢谢@Andersson

相关内容

  • 没有找到相关文章

最新更新