簡體   English   中英

使用Python Selenium單擊網頁中的“顯示更多交易”

[英]Click on “Show more deals” in webpage with 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM