Selenium+Python+Internet Explorer+公司代理+PAC文件+凭证

2024-04-19 03:27:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Selenium+Python浏览互联网。 不幸的是,在我的公司,它不能与internetexplorer一起工作(但它可以与Chrome一起工作),这肯定是因为我的公司有一个代理,并且需要使用PAC文件来浏览互联网。在

这是我的代码:

from selenium import webdriver
from selenium.webdriver.common.proxy import ProxyType
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.ie.webdriver import WebDriver as Ie


ie_path=...
url_of_the_pac_file=...

caps = DesiredCapabilities.INTERNETEXPLORER
caps["proxy"] = {"proxyType": "pac","proxyAutoconfigUrl": url_of_the_pac_file}


driver=Ie(executable_path=ie_path,capabilities=caps,port=8080)
driver.get("http://www.google.com")

每次运行此代码时,我都会收到以下消息:

^{pr2}$

这似乎需要我的证书,但我不知道怎么做。 谢谢你的帮助!在


Tags: path代码fromimportselenium公司互联网common