【问题标题】:Click on “Show more deals” in webpage with Python Selenium使用 Python Selenium 在网页中单击“显示更多交易”
【发布时间】:2019-09-13 08:37:19
【问题描述】:

我正在使用以下代码单击“显示更多评论”按钮,但无法正常工作。

代码:

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)

提前致谢。

【问题讨论】:

  • 为什么为真??

标签: python web-scraping nlp selenium-chromedriver


【解决方案1】:

找到了答案。

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

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

【讨论】:

    猜你喜欢
    • 2019-04-22
    • 2016-09-17
    • 2019-11-18
    • 1970-01-01
    • 2021-06-23
    • 1970-01-01
    • 1970-01-01
    • 2021-11-01
    • 1970-01-01
    相关资源
    最近更新 更多