[英]IE webdriver of Selenium Python loads the webpage and goes to a halt state
嘿,Python 專家,我已經使用 Beautiful Soup 和 REquests 從 static web 中為我的項目抓取數據。 但是對於動態內容,我無法做到這一點。 我已經安裝了 selenium 。 但是當我執行下面的代碼時; 打開瀏覽器后,代碼進入睡眠模式。 我在我的操作 window 中只能看到“1Test”。
請幫忙:)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Ie(executable_path='IEDriverServer_Win32_3.150.1/IEDriverServer.exe')
print('1test')
driver.get('http://www.google.com')
print('2test')
driver.close()
print('3test')
driver.quit()
您需要通過使用暫時停止程序的執行
driver.sleep(<number of seconds>)
或通過導入時間模塊並編寫
time.sleep(<number of seconds>)
這需要在每一步之后完成。
這需要完成網頁上的不同元素需要時間來加載,因此如果在它們完全加載之前調用,selenium 將無法訪問它們並會引發錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.