2017-10-11 239 views
0

我試圖刮掉此網頁的結果:Python網絡刮硒/請求

https://results.chronotrack.com/event/results/event/event-24381

這是我可以手動執行:

1)打開上述網址鉻

2)點擊結果標籤

2.5)有時改變種族距離

3)單擊下一步去2頁

4)打開開發工具/網絡

5)單擊上一步回到第一頁

6)獲取從結果的請求URL -Grid回調元素從開發工具:

https://results.chronotrack.com/embed/results/results-grid?callback=results_grid17740402&sEcho=7&iColumns=11&sColumns=&iDisplayStart=0&iDisplayLength=100&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&mDataProp_4=4&mDataProp_5=5&mDataProp_6=6&mDataProp_7=7&mDataProp_8=8&mDataProp_9=9&mDataProp_10=10&raceID=60107&bracketID=638654&intervalID=121077&entryID=&eventID=24381&eventTag=event-24381&oemID=www.chronotrack.com&genID=17740402&x=1507682443198&_=1507682443198

一旦我得到了這麼遠,我可以操縱DisplayStart參數,以獲得結果的其餘部分。

有我的方式找到使用要求和/或硒那樣的網址是什麼?硒我試圖打開的第一個頁面然後單擊到的結果與以下幾點:

driver.find_element_by_id('resultsResultsTab').click() 

,但我得到了以下錯誤:

Element is not currently visible and may not be manipulated 

誰能幫我指出了正確的方向?

回答

1

儘量等到需要的元素變得可見:

from selenium.webdriver.support.ui import WebDriverWait as wait 
from selenium.webdriver.support import expected_conditions as EC 
from selenium.webdriver.common.by import By 

wait(driver, 10).until(EC.visibility_of_element_located((By.ID, 'resultsResultsTab'))).click() 
+0

這工作,謝謝! – user3449833