点击";“加载更多”;用python在网页上的应用

点击";“加载更多”;用python在网页上的应用,python,html,python-3.x,web,selenium-webdriver,Python,Html,Python 3.x,Web,Selenium Webdriver,我正在尝试加载此文件的全部内容(单击) 我尝试了很多类似的教程,教我如何处理类似的问题(无限滚动页面) 我的问题是,我无法在此页面上指定load more类来单击它。但是,如果我没有弄错的话,它存在于网页源代码的这一部分: <ng-include src="'loader.html'" class="ng-scope"> <div class="loading-div ng-scope ng-hide" ng-show="!loadingMoreData">

我正在尝试加载此文件的全部内容(单击)

我尝试了很多类似的教程,教我如何处理类似的问题(无限滚动页面)

我的问题是,我无法在此页面上指定load more类来单击它。但是,如果我没有弄错的话,它存在于网页源代码的这一部分:

<ng-include src="'loader.html'" class="ng-scope">
    <div class="loading-div ng-scope ng-hide" ng-show="!loadingMoreData">
        <div class="spinner">
            <div class="bounce1"></div>
            <div class="bounce2"></div>
            <div class="bounce3"></div>
        </div>
    </div>
</ng-include>
<div class="block-hed block-link clearfix" data-ng-show="isMoreDisplayed" data-ng-click="getMoreMaterials()">
                    <h4 class="link-border-color"><a href="javascript:void(0)">المزيد </a></h4>
                </div>

更新 我在这里用这个来解决这个问题,但是没有一个教程有效

find_element_by_id
find_element_by_name
find_element_by_xpath
find_element_by_link_text
find_element_by_partial_link_text
find_element_by_tag_name
find_element_by_class_name
find_element_by_css_selector

我终于设法解决了这个问题。我只是在我的代码后面加了这一行

while True:
    browser.find_elements_by_link_text('المزيد')[1].click()

页面开始无限加载所有的文章。我真的不知道它本身是可点击的。我认为其中包含一个链接。

正确/更好的方法是使用WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
while True:
  element = wait.until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, 'المزيد')))
  element.click()
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
while True:
  element = wait.until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, 'المزيد')))
  element.click()