Auto.js 网络请求代理设置:控制数据是否走VPN和代理
"使用Auto.js,如何让代码中的那些数据不走VPN和代理"\n在Auto.js中,可以通过设置网络请求的代理来控制代码中的数据是否走VPN和代理。以下是一个示例代码,演示如何设置代理:\n\njavascript\n// 打开VPN和代理开关\nshell\("settings put global http_proxy 127.0.0.1:8888\", true\);\nshell\("settings put global global_http_proxy_host 127.0.0.1:8888\", true\);\nshell\("settings put global global_http_proxy_port 8888\", true\);\n\n// 发送网络请求\nhttp.get\("https://example.com\", {\n headers: {\n \"User-Agent\": \"Auto.js\"\n },\n handler: function (res) {\n // 处理响应数据\n var data = res.body.string();\n toastLog(data);\n }\n});\n\n// 关闭VPN和代理开关\nshell\("settings delete global http_proxy\", true\);\nshell\("settings delete global global_http_proxy_host\", true\);\nshell\("settings delete global global_http_proxy_port\", true\);\n\n\n以上代码首先打开VPN和代理开关,然后发送网络请求,最后关闭VPN和代理开关。通过设置全局的 http_proxy 和 global_http_proxy_host 和 global_http_proxy_port 属性,可以将网络请求流量重定向到指定的代理服务器。你可以根据自己的代理设置进行相应的修改。\n\n注意:这里使用的是 Android 系统的设置命令,需要在有 Root 权限的设备上运行,或者在已经授权的 Auto.js 中运行。\n\n希望对你有帮助!
原文地址: https://www.cveoy.top/t/topic/p5QE 著作权归作者所有。请勿转载和采集!