找出WebDriver与Chrome一起使用的代理服务器

时间:2018-07-24 06:32:41

标签: python selenium

我通过代理在Chrome中运行硒。

from selenium import webdriver
from selenium.webdriver import Chrome

chrome_options = webdriver.ChromeOptions()

a_proxy = '94.242.58.108:1448'
# chrome_options.add_argument('--proxy-server={}'.format(a_proxy))
# driver = Chrome(chrome_options=chrome_options, )

desired_capabilities = DesiredCapabilities.CHROME.copy()
desired_capabilities["proxy"] = {'proxyType': 'MANUAL',
         'httpProxy': a_proxy, 'autodetect': False}
driver = Chrome(desired_capabilities=desired_capabilities)

两个示例都被注释,而未注释的示例则完美地工作了。我检查了一个显示IP的网站。因此,代理服务器是有组织的。

换句话说,驱动程序知道它现在正在使用哪个代理服务器。

任务是:具有驱动程序变量(即Chrome对象),找出它正在使用的代理服务器。

好吧,我在一个断点处停下来,看一看desirable_capabilities内部的内容。没有代理。

您能告诉我有关使用的代理的信息隐藏在哪里吗?任何方法都适合我。即使应该更改整个代码。我只需要从Chrome实例中提取的信息即可。

enter image description here

0 个答案:

没有答案