为下一页加载“更多”按钮?

为下一页加载“更多”按钮?

问题描述:

我正在尝试点击“更多”按钮来获取下一组页面。为下一页加载“更多”按钮?

下一页链接HTML标签:

<span id="direct_moreLessLinks_listingDiv" class="more_less_links_container" data-num-items="15" offset="45" data-type="listing"> 
 
<a id="button_moreJobs" rel="nofollow" href="#">More</a> 
 
</span>

注:当我点击 “更多” 按钮。它将在同一页面中加载下一页。

我试图用硒点击下一页:

部分代码:

self.driver.get('example.com') 
 
     while True: 
 
      more_btn = WebDriverWait(self.driver, 10).until(
 
       EC.visibility_of_element_located((By.ID, "More")) 
 
      ) 
 

 
      More.click() 
 

 
      # stop when we reach the desired page 
 
    

通过ID找到链接并单击它:

more_btn = WebDriverWait(self.driver, 10).until(
       EC.visibility_of_element_located((By.ID, "button_moreJobs")) 
      ) 
more_btn.click() 

因为这是一个while True循环,所以您需要找出一种方法来停止分页并打破循环。由于您尚未提供您正在使用的实际页面,因此我只能对此进行猜测。