第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

陷入 for 循環(huán) - 沒有“下一步按鈕”

陷入 for 循環(huán) - 沒有“下一步按鈕”

動漫人物 2021-10-26 16:04:23
我正在嘗試在 Rotogrinder/Resultdb 上抓取特定日期參加比賽的所有團隊。但是,我剛剛意識到,當被抓取的比賽條目少于 50 個(只有一頁)時,我的代碼會停留在循環(huán)中,因為我通常使用下一步按鈕退出該循環(huán)。這是我的代碼:*** 我改三行直接去比賽,出現(xiàn)問題。#Packages:from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ecimport pandas as pdimport timefrom selenium.common.exceptions import NoSuchElementException# Driverchromedriver =("C:/Users/Michel/Desktop/python/package/chromedriver_win32/chromedriver.exe")driver = webdriver.Chrome(chromedriver)# DF taht will be use later results = pd.DataFrame()best_lineups=pd.DataFrame()opti_lineups=pd.DataFrame()#For loop over all DATES:CALENDAR=[]CALENDAR.append("2017-10-04")CALENDAR.append("2017-10-05")for d in CALENDAR:    driver.get("https://rotogrinders.com/resultsdb/date/"+d+"/sport/4/")       time.sleep(10)                try:                contest= driver.find_element_by_xpath("//*[@id='root']/div/main/main/div[2]/div[3]/div/div/div[1]/div/div/div/div/div[3]")              contest.click()        list_links = driver.find_elements_by_tag_name('a')        hlink=[]        for ii in list_links:            hlink.append(ii.get_attribute("href"))        sub="https://rotogrinders.com/resultsdb"        con= "contest"        contest_list=[]        for text in hlink:            if sub in text:                if con in text:                    contest_list.append(text)                    # comment next two lines and replace by following three to get directly to where the code keep looping                   #         for c in contest_list:#             driver.get(c)               c=contest_list[3:5]        for a in c:                        driver.get(a)                       n=1            while n<100:                  n+=1                time.sleep(10)        我怎么能解決這個問題?
查看完整描述

2 回答

?
倚天杖

TA貢獻1828條經(jīng)驗 獲得超3個贊

try:

    next_button =  driver.find_elements_by_xpath("//button[@type='button']")

    next_button[2].click()    

 except NoSuchElementException:

    n = 100

    break

您的頁面控制變量是n,將其設(shè)置為 100,while 循環(huán)將停止。


查看完整回答
反對 回復 2021-10-26
?
回首憶惘然

TA貢獻1847條經(jīng)驗 獲得超11個贊

嘗試使用webElement.isEnabled()和來檢查按鈕是否已啟用webElement.isDisplayed()。這里有一個約可點擊元素。



查看完整回答
反對 回復 2021-10-26
  • 2 回答
  • 0 關(guān)注
  • 180 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號