首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在带有Python Selenium的网页中点击“Show more deals”

在带有Python Selenium的网页中点击“Show more deals”
EN

Stack Overflow用户
提问于 2019-09-13 16:37:19
回答 1查看 28关注 0票数 0

我正在使用下面的代码点击“显示更多评论”按钮,但不起作用。

代码:

代码语言:javascript
复制
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")

错误语句

代码语言:javascript
复制
NoSuchElementException: no such element: Unable to locate element: {"method":"partial link text","selector":"Show more reviews"}
(Session info: headless chrome=76.0.3809.132)

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57920074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档