我正试图在无头模式下使用Firefox运行selenium连接:
from seleniumwire import webdriver
options = {
'proxy': {
'http': 'http://user:password@ip:port',
'https': 'https://user:password@ip:port',
'no_proxy': 'localhost,127.0.0.1,dev_server:8080'
},
'headless': True
}
driver = webdriver.Firefox(seleniumwire_options=options)
driver.get("http://adream.es")它没有产生任何效果,因为浏览器窗口仍然弹出:
在selenium中,通常我运行它的方式如下:
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
driver.get("http://adream.es")我怎么才能无头运行呢?
发布于 2022-09-09 09:22:17
我不得不查看seleniumwire文件,这个组合对我有效。
from selenium.webdriver import FirefoxOptions
from seleniumwire import webdriver as seleniumwire_webdriver
fireFoxOptions = FirefoxOptions()
fireFoxOptions.headless = True
seleniumwire_options = {
'proxy': {
'http': 'http://user:password@ip:port',
'https': 'https://user:password@ip:port',
'no_proxy': 'localhost,127.0.0.1,dev_server:8080'
}
}
driver = webdriver.Firefox(
options=fireFoxOptions,
seleniumwire_options=seleniumwire_options )快乐刮擦
https://stackoverflow.com/questions/73492862
复制相似问题