全球电脑论坛,电脑问题求救!sos
python-drissionpage 然后用了快代理,那种写入浏览器插件的方式 使用快代理:
系统:macos
现在关了程序,所有的浏览器 只要不开代理 就无**常上网,包括safari也是一样的
现在浏览器想正常上网就得 开小火箭,不开小火箭就报错 ,请问各位大佬咋解决?
[*]def create_proxyauth_extension(proxy_host, proxy_port, proxy_username, proxy_password, scheme='http', plugin_folder=None):
[*] if plugin_folder is None:
[*] plugin_folder = 'kdl_Chromium_Proxy'# 插件文件夹名称
[*] if not os.path.exists(plugin_folder):
[*] os.makedirs(plugin_folder)
[*] manifest_json = """
[*] {
[*] "version": "1.0.0",
[*] "manifest_version": 2,
[*] "name": "kdl_Chromium_Proxy",
[*] "permissions": [
[*] "proxy",
[*] "tabs",
[*] "unlimitedStorage",
[*] "storage",
[*] "",
[*] "webRequest",
[*] "webRequestBlocking",
[*] "browsingData"
[*] ],
[*] "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: []
[*] }
[*] };
[*]
[*] chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
[*]
[*] function callbackFn(details) {
[*] return {
[*] authCredentials: {
[*] username: "${username}",
[*] password: "${password}"
[*] }
[*] };
[*] }
[*]
[*] chrome.webRequest.onAuthRequired.addListener(
[*] callbackFn,
[*] {urls: [""]},
[*] ['blocking']
[*] );
[*] """).substitute(
[*] host=proxy_host,
[*] port=proxy_port,
[*] username=proxy_username,
[*] password=proxy_password,
[*] scheme=scheme,
[*] )
[*] with open(os.path.join(plugin_folder, "manifest.json"), "w") as manifest_file:
[*] manifest_file.write(manifest_json)
[*] with open(os.path.join(plugin_folder, "background.js"), "w") as background_file:
[*] background_file.write(background_js)
[*] return plugin_folder
[*]
[*]proxyauth_plugin_folder = create_proxyauth_extension(
[*] proxy_host=tunnelhost,
[*] proxy_port=tunnelport,
[*] proxy_username=username,
[*] proxy_password=password
[*])复制代码
页:
[1]