为了账号安全,请及时绑定邮箱和手机立即绑定

脚本无法继续点击加载更多按钮

脚本无法继续点击加载更多按钮

猛跑小猪 2021-06-07 09:33:48
我已经用 Python 编写了一个与 selenium 相关的脚本,以不断单击MORE按钮以加载更多项目,直到没有新项目可以从网页加载为止。但是,我的以下脚本可以单击MORE该页面底部可用的按钮一次。到目前为止,这是我的尝试:from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as EClink = "https://angel.co/companies?company_types[]=Startup&company_types[]=Private+Company&company_types[]=Mobile+App&locations[]=1688-United+States"driver = webdriver.Chrome()wait = WebDriverWait(driver, 10)driver.get(link)while True:    for elems in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,".results .name a.startup-link"))):        print(elems.get_attribute("href"))    try:        loadmore = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR,"[class='more']")))        driver.execute_script("arguments[0].scrollIntoView();", loadmore)        loadmore.click()    except Exception:breakdriver.quit()我怎么能一直点击那个MORE按钮,直到没有这样的按钮可以点击和解析链接,因为我已经尝试过使用for loop.
查看完整描述

添加回答

代码语言

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号