经测试app,包括b站可走代理ip显示代理ip地址
**
Autojs设置系统代理:
**
function setProxyWithAPI() {
// 清除现有代理设置
shell("settings delete global http_proxy", true);
shell("settings delete global global_http_proxy_host", true);
shell("settings delete global global_http_proxy_port", true);
shell("settings delete global global_http_proxy_user", true);
shell("settings delete global global_http_proxy_password", true);
// 访问API获取新的代理信息
var apiUrl = "你的代理api";
// 经测试自行设置白名单,不然的话自动设置代理用户名密码可能不会生效
// 响应格式
// {
// "ret": 200,
// "data": [
// {
// "ip": "114.106.171.74",
// "port": "1764",
// "user": "495023092",
// "pwd": "495023092",
// "deadline": "2024-04-26 19:25:17",
// "prov": "安徽",
// "city": "池州",
// "isp": "电信",
// "outip": "114.106.171.74"
// }
// ],
// "msg": ""
// } 如响应格式不一样需自行调整下面的json格式
var response = http.get(apiUrl);
if (response.statusCode != 200) {
toast("API 请求失败");
return;
}
// 解析API返回的代理信息
var responseData = JSON.parse(response.body.string());
if (responseData.ret !== 200) {
toast("API 返回错误:" + responseData.msg);
return;
}
// 提取代理信息
var proxyInfo = responseData.data[0];
var host = proxyInfo.ip;
var port = proxyInfo.port;
var user = proxyInfo.user;
var password = proxyInfo.pwd;
// 设置新的代理
shell("settings put global http_proxy " + host + ":" + port, true);
shell("settings put global global_http_proxy_host " + host, true);
shell("settings put global global_http_proxy_port " + port, true);
shell("settings put global global_http_proxy_user " + user, true);
shell("settings put global global_http_proxy_password " + password, true);
log("代理设置成功: " + host + ":" + port + ", 用户名: " + user + ", 密码: " + password);
}
setProxyWithAPI();
**
到这里就换好了ip,接下来是清除系统代理这里面有坑
目前百度到的都是叫你
**
// 清除代理设置
shell("settings delete global http_proxy", true);
shell("settings delete global global_http_proxy_host", true);
shell("settings delete global global_http_proxy_port", true);
shell("settings delete global global_http_proxy_user", true);
shell("settings delete global global_http_proxy_password", true);
log("代理设置已清除");
**
实际上是没用的,经过自己实践有用的是下面的
**
shell ("settings put global http_proxy :0", true);
仅需一行。。。
qliu99