有偿求官方实例 讯代理 http 优质代理源码

官方代码报错 写不好。求能正常使用的源码

管理员

源代码贴出来看看

console.show();
var spiderId = "18b2330241244cbbb367facbaf2d9de7"; //spiderId
var orderNo = "YZ201812131722eDjXV6"; //订单号

var getIp_api = http.get('http://pv.sohu.com/cityjson?ie=utf-8');
var InetIP = getIp_api.body.string();
eval(InetIP);
log("使用代理前的外网IP:"+returnCitySN.cip);

var xdailiUrl = "http://api.xdaili.cn/xdaili-api//greatRecharge/getGreatIp?spiderId="+spiderId+"&orderno="+orderNo+"&returnType=2&count=1";

for (let i = 0; i < 3; i++) {
try {
var getProxy_json = http.get(xdailiUrl).body.json();

	if (getProxy_json.ERRORCODE == "10036" || getProxy_json.ERRORCODE == "10038" || getProxy_json.ERRORCODE == "10055") {
		throw {
			"code" : "-1",
			"msg"  : "提取速度过快"
		}
	}
	if (getProxy_json.ERRORCODE == "10036") {
		throw {
			"code" : "-2",
			"msg"  : "提取次数已达上限"
		}
	}
	break;
	} catch (e) {
	if (e.code == "-1") {
		log(e.msg);
		sleep(5000);
	} 
	if (e.code == "-2") {
		log(e.msg);
		exit();
	}
	if (i == 2) { //运行3次后,没有拿到IP和端口 程序结束
		log("发生了未知错误,请检查网络...");
		exit();
	}
}

sleep(400);	

}

log(getProxy_json );
var xdaili_proxyIP = getProxy_json.RESULT[0].ip;
var xdaili_proxyPort = parseInt(getProxy_json.RESULT[0].port);
log(xdaili_proxyIP+":"+xdaili_proxyPort + "ip+端口" );

httpProxy(xdaili_proxyIP, xdaili_proxyPort);

var getIp_api = http.get('http://pv.sohu.com/cityjson?ie=utf-8');
var InetIP = getIp_api.body.string();
eval(InetIP);
log("使用代理后的外网IP:"+returnCitySN.cip);

function httpProxy(url,prot) {
var Proxy = java.net.Proxy;
var InetSocketAddress = java.net.InetSocketAddress;
var okhttp = new Packages.okhttp3.OkHttpClient.Builder().proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(url, prot)));
http.okhttp.muteClient(okhttp);
}
//////日志
2018年12月26日11时35分8秒:启动服务-用手机输入电脑ip:192.168.2.158
11:37:12→手机日志: 已经连上手机名称:Xiaomi MI 4
11:37:19→Xiaomi MI 4 →系统日志: 开始运行[[remote]12新建文件.js]
11:37:19→Xiaomi MI 4 →手机日志: 使用代理前的外网IP:27.26.136.32
11:37:19→Xiaomi MI 4 →手机日志:
11:37:19→Xiaomi MI 4 →手机日志: 122.237.245.158:45934ip+端口
11:37:19→Xiaomi MI 4 →错误日志: TypeError: Cannot find function muteClient in object com.stardust.autojs.core.http.MutableOkHttp@a72b5e9. (<[remote]12新建文件>#69)\n\tat script.httpProxy(<[remote]12新建文件>:69)\n\tat script(<[remote]12新建文件>:58)
11:37:19→Xiaomi MI 4 →结束日志: [[remote]12新建文件.js]运行结束,用时0.336000秒

  • 4
    帖子
  • 935
    浏览

与 Auto.js 的连接断开,我们正在尝试重连,请耐心等待