亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

如何修復 Python 中的 selenium“DevToolsActivePort 文件不存在”

如何修復 Python 中的 selenium“DevToolsActivePort 文件不存在”

慕村9548890 2022-03-09 20:47:10
當我同時使用參數--headless和user-data-dir. 硒引發selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist異常。如果只使用其中一個,那么一切都按需要進行。我試圖交換論點并刪除其中一些。指定 chromedriver.exe 的完整路徑。這些都沒有幫助。chromeOptions.add_argument("--disable-dev-shm-using") 沒有幫助我。login = "test"chromeOptions = webdriver.ChromeOptions() chromeOptions.add_experimental_option("prefs", {"profile.managed_default_content_settings.images": 2}) chromeOptions.add_argument("--no-sandbox") chromeOptions.add_argument("--disable-setuid-sandbox") chromeOptions.add_argument("--disable-dev-shm-using") chromeOptions.add_argument("--disable-extensions") chromeOptions.add_argument("--disable-gpu") chromeOptions.add_argument("start-maximized") chromeOptions.add_argument("disable-infobars") chromeOptions.add_argument("--headless") chromeOptions.add_argument(r"user-data-dir=.\cookies\\" + login) b = webdriver.Chrome(chrome_options=chromeOptions) b.get("https://google.com/") b.quit() 
查看完整描述

1 回答

?
蝴蝶刀刀

TA貢獻1801條經驗 獲得超8個贊

我通過添加參數來解決它--remote-debugging-port=<port>


chromeOptions = webdriver.ChromeOptions() 

chromeOptions.add_experimental_option("prefs", {"profile.managed_default_content_settings.images": 2}) 

chromeOptions.add_argument("--no-sandbox") 

chromeOptions.add_argument("--disable-setuid-sandbox") 


chromeOptions.add_argument("--remote-debugging-port=9222")  # this


chromeOptions.add_argument("--disable-dev-shm-using") 

chromeOptions.add_argument("--disable-extensions") 

chromeOptions.add_argument("--disable-gpu") 

chromeOptions.add_argument("start-maximized") 

chromeOptions.add_argument("disable-infobars")

chromeOptions.add_argument(r"user-data-dir=.\cookies\\test") 


b = webdriver.Chrome(chrome_options=chromeOptions) 

b.get("https://google.com/") 

b.quit()


查看完整回答
反對 回復 2022-03-09
  • 1 回答
  • 0 關注
  • 217 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號