我正在使用 selenium 和 python 來抓取網站上的資料。
問題是我需要手動登錄,因為登錄后有驗證碼。
我的問題如下:有沒有辦法在已經加載的頁面上啟動程式?(例如,我會登錄網站,手動解決驗證碼,然后啟動會抓取資料的程式)
注意:我一直在尋找關于 SO 的答案,但沒有找到,可能已經錯過了,因為它似乎是一個明顯的問題。
uj5u.com熱心網友回復:
不要在無頭模式下打開。以頭部模式打開。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
options = Options()
options.headless = False # Set false here
driver = webdriver.Chrome(options=options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get("http://google.com/")
print ("Headless Chrome Initialized")
time.sleep(30) # wait 30 seconds, this should give enough time to manually do the capture
# do other code here
driver.quit()
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/329059.html
