from selenium import webdriver
import string
import zipfile
# 打包Google代理插件
def create_proxyauth_extension(proxy_host, proxy_port, proxy_username, proxy_password, scheme='http', plugin_path=None):
if plugin_path is None:
# 插件地址
plugin_path = 'C:/Program Files (x86)/Google/Chrome/Application/vimm_chrome_proxyauth_plugin.zip' manifest_json = """
{
"version": "1.0.0",
"manifest_version": 2,
"name": "Chrome Proxy",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
},
"minimum_chrome_version":"22.0.0"
}
""" background_js = string.Template(
"""
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "${scheme}",
host: "${host}",
port: parseInt(${port})
},
bypassList: ["foobar.com"]
}
}; chrome.proxy.settings.set({value: config, scope: "regular"}, function() {}); function callbackFn(details) {
return {
authCredentials: {
username: "${username}",
password: "${password}"
}
};
} chrome.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
['blocking']
);
"""
).substitute(
host=proxy_host,
port=proxy_port,
username=proxy_username,
password=proxy_password,
scheme=scheme,
)
with zipfile.ZipFile(plugin_path, 'w') as zp:
zp.writestr("manifest.json", manifest_json)
zp.writestr("background.js", background_js) return plugin_path # 填写主机地址,端口,账号,密码
proxyauth_plugin_path = create_proxyauth_extension(
proxy_host="****",
proxy_port=808,
proxy_username="****",
proxy_password="****"
)
# 测试
co = webdriver.ChromeOptions()
co.add_argument("--start-maximized")
co.add_extension('C:/Program Files (x86)/Google/Chrome/Application/vimm_chrome_proxyauth_plugin.zip')
driver = webdriver.Chrome(chrome_options=co)
driver.get("http://www.google.cn/")

python3 - selenium 添加有账号密码的代理的更多相关文章

  1. python3 mqtt 添加用户名以及密码

    import paho.mqtt.client as mqtt client = mqtt.Client(client_id, transport='tcp') client.username_pw_ ...

  2. openvpn部署账号密码登录

    1.开启服务器端路由转发功能: 修改配置文件/etc/sysctl.conf中 net.ipv4.ip_forward = 0 改为 net.ipv4.ip_forward = 1 [root@nod ...

  3. PHP CURL 账号密码 添加授权Authorization头Header

    <?phpfunction http_request_xml($url,$data = null,$arr_header = null){ $curl = curl_init(); curl_s ...

  4. Linux下添加FTP账号和服务器、增加密码和用户,更改FTP目录

    1. 启动VSFTP服务器 A:cenos下运行:yum  install  vsftpd B. 登录Linux主机后,运行命令:”service vsftpd start” C. 要让FTP每次开机 ...

  5. chromedriver 代理设置(账号密码)

    在使用selenium时遇到的一个问题 如何为chromedriver设置有密码的代理 在借鉴了stackoverflow上的答案 background.js var config = { mode: ...

  6. selenium(python)登录时账号密码错误提示语

    selenium(python)登录时账号密码错误提示语的获取 可以用text

  7. 使用selenium进行密码破解(绕过账号密码JS加密)

    经常碰到网站,账号密码通过js加密后进行提交.通过burp拦截抓到的账号密码是加密后的,所以无法通过burp instruder进行破解.只能模拟浏览器填写表单并点击登录按钮进行破解.于是想到了自动化 ...

  8. 【转】Linux下添加FTP账号和服务器、增加密码和用户,更改FTP目录

    转自:http://blog.csdn.net/cloudday/article/details/8640234   1. 启动VSFTP服务器 A:cenos下运行:yum  install  vs ...

  9. python3 selenium模块Chrome设置代理ip的实现

    python3 selenium模块Chrome设置代理ip的实现 selenium模块Chrome设置代理ip的实现代码: from selenium import webdriver chrome ...

随机推荐

  1. 微信小程序开发(一)基础知识学习

    1.特点:   ①无DOM对象(虚拟DOM),一切基于组件化(复用.解耦) ②四个重要文件: *.js.*.wxml --> html..wxss --> css.*.json ③无需下载 ...

  2. webserver 返回json 如何去掉 <string xmlns="http://tempuri.org/">

    [WebMethod]  public void GetJson(String sJson)  {    Context.Response.Charset = "UTF-8"; / ...

  3. 萌新学渗透系列之Hack The Box_Devel

    我将我的walkthrough过程用视频解说的形式记载 视频地址https://www.bilibili.com/video/BV1Ck4y1B7DB 一是因为看我视频的后来者应该都是刚入门的新手,视 ...

  4. JAVA JDBC Template的使用

    JAVA JDBC Template的使用 什么是Template? Spring框架对JDBC的简单封装.提供了一个JDBCTemplate对象简化JDBC的开发 Template使用步骤 导入ja ...

  5. Fortify Audit Workbench Cookie Security: Cookie not Sent Over SSL

    Abstract 所创建的 cookie 的 secure 标记没有设置为 true. Explanation 现今的 Web 浏览器支持每个 cookie 的 secure 标记. 如果设置了该标记 ...

  6. 线程_gevent实现多个视频下载及并发下载

    from gevent import monkey import gevent import urllib.request #有IO操作时,使用patch_all自动切换 monkey.patch_a ...

  7. Django学习路6_修改数据库为 mysql ,创建mysql及进行迁徙

    在项目的 settings 中修改 DATABASES = { 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os. ...

  8. Codeforces Round #649 (Div. 2) E. X-OR 交互 二进制 随机 期望

    LINK:X-OR 本来是应该昨天晚上发的 可是昨天晚上 做这道题 写了一个分治做法 一直wa 然后查错 查不出来 心态崩了 想写对拍 发现交互库自己写不出来. 一系列sb操作 == 我都醉了. 今天 ...

  9. 牛客练习赛63 C 牛牛的揠苗助长 主席树 二分 中位数

    LINK:牛牛的揠苗助长 题目很水 不过做法很多 想到一个近乎O(n)的做法 不过感觉假了 最后决定莽一个主席树 当然 平衡树也行. 容易想到 答案为ans天 那么一些点的有效增长项数为 ans%n. ...

  10. MyBatis辟邪剑谱

    一 MyBatis简介 MyBatis是一个优秀的持久层框架 它对JDBC操作数据库的过程进行封装 开发者只需要关注SQL本身 而不需要花费精力去处理JDBC繁杂的过程代码 MyBatis将要执行的各 ...