【发布时间】:2018-07-29 05:15:45
【问题描述】:
我正在为 python 使用带有 selenium 的 chromedriver。
我想为扩展保存一些设置,以便每次我使用该扩展加载 chromedriver 时设置都会返回。 见下文,我想保存用户名和密码
我目前正在加载扩展,如下所示。
def __init__(self):
capa = DesiredCapabilities.CHROME
capa["pageLoadStrategy"] = "none"
chrome_options = Options()
chrome_options.add_extension('/home/simonsays/PycharmProjects/lbc_piscine_spider/chrome_extentions/Cookie-AutoDelete_v2.1.2.crx')
chrome_options.add_extension('/home/simonsays/PycharmProjects/lbc_piscine_spider/chrome_extentions/Random-User-Agent_v2.1.10.crx')
chrome_options.add_extension('/home/simonsays/PycharmProjects/lbc_piscine_spider/chrome_extentions/Proxy-Auto-Auth_v2.0.crx')
self.driver1 = webdriver.Chrome("/var/chromedriver/chromedriver", desired_capabilities=capa,chrome_options=chrome_options)
【问题讨论】:
-
程序每次运行时都必须使用空白配置文件吗?如果没有,请考虑在另一个配置文件/默认配置文件中加载
extension。阅读this 以供参考。这样,为该配置文件保存的设置/扩展应该在每次启动程序时加载。
标签: python selenium web-scraping selenium-chromedriver