栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在OperaDriver中启用内置VPN?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在OperaDriver中启用内置VPN?

您正尝试从https://seleniumhq.github.io/selenium/docs/api/py/webdriver_opera/selenium.webdriver.opera.webdriver.html使用OperaOptions而不是ChromeOptions

options:这需要一个ChromeOptions的实例

正如卡乔所说

“从GUI启用VPN,设置已保存在活动配置文件中。”

from selenium import webdriverfrom time import sleep# The profile where I enabled the VPN previously using the GUI.opera_profile = '/home/dan/.config/opera' options = webdriver.ChromeOptions()options.add_argument('user-data-dir=' + opera_profile)driver = webdriver.Opera(options=options)driver.get('https://whatismyipaddress.com')sleep(10)driver.quit()

结果:

First tryIPv6: 2001:67c:2660:425:2:0:0:3f8IPv4: 77.111.247.26Second tryIPv6: 2001:67c:2660:425:1a:0:0:1a0IPv4: 77.111.247.66Third tryIPv4: 77.111.247.133IPv6: Not detectedForth tryIPv6: 2001:67c:2660:425:1c:0:0:1feIPv4: 77.111.247.68

我的IP都没有,VPN图标也显示在地址栏旁边。

更新 以回应问题。

来自https://techdows.com/2016/08/opera-profile-
location.html

知道Opera的配置文件路径的简单方法是在地址栏中键入about:// about,然后检查路径下的Profile行。

在Windows 10上,代码如下所示。

from selenium import webdriverfrom time import sleep# The profile where I enabled the VPN previously using the GUI.opera_profile = r'C:\Users\dan\AppData\Roaming\Opera Software\Opera Stable' options = webdriver.ChromeOptions()options.add_argument('user-data-dir=' + opera_profile)options._binary_location = r'C:\Users\dan\AppData\Local\ProgramsOpera\58.0.3135.114\opera.exe'driver = webdriver.Opera(executable_path=r'C:\operadriver_win64\operadriver.exe',options=options)driver.get('https://whatismyipaddress.com')sleep(10)driver.quit()


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/634118.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号