本文所有教程及源码、软件仅为技术钻研。不波及计算机信息零碎性能的删除、批改、减少、烦扰,更不会影响计算机信息零碎的失常运行。不得将代码用于非法用处,如侵立删! |
**
## Auto.js get 和 post 案例
### 操作环境
– win10
– nexus5x
– Auto.js 7.0.4
### get 案例
#### 简略 GET 申请
`
javascript
console.show();
var r = http.get(“www.baidu.com”);
log(“code = ” + r.statusCode);
log(“html = ” + r.body.string());
`
#### 回调模式的 GET 申请
`
javascript
console.show();
http.get(“www.baidu.com”, {}, function(res, err){
if(err){
console.error(err);
return;
}
log(“code = ” + res.statusCode);
log(“html = ” + res.body.string());
});
`
#### get 案例 demo
`
javascript
console.show();
http.get(“https://**/?uid=857fcfb50b474ef1cc7fa1b07e&ty=2″, {}, function(res, err){
if(err){
console.error(err);
return;
}
log(“code = ” + res.statusCode);
log(“html = ” + res.body.string());
});
`
### post 案例
#### 简略 post
`
javascript
var url = “https://login.taobao.com/member/login.jhtml”;
var username = username ;
var password = password ;
var res = http.post(url, {
“TPL_username”: username,
“TPL_password”: password
});
var html = res.body.string();
if(html.contains(“ 页面跳转中 ”)){
toast(“ 登录胜利 ”);
}else{
toast(“ 登录失败 ”);
}
`
#### postJson
以 JSON 格局向指标 Url 发动 POST 申请
`
javascript
var url = “http://www.tuling123.com/openapi/api”;
r = http.postJson(url, {
key: “65458a5df537443b89b31f1c03202a80”,
info: “ 你好啊 ”,
userid: “1”,
});
toastLog(r.body.string());
`
#### post 案例 demo
`
javascript
// 接口地址
var url = “”;
var res = http.post(url, {
“payid”: payid,
“password”: password,
“amount”: amount,
“remark”: remark,
“username”: username,
“password”: password,
“timestamp”: timestamp
});
var html = res.body.string();
log(html);
`
**
## 资源下载
https://download.csdn.net/download/qq_38154948/86267597
**
本文仅供学习交换应用,如侵立删! |
**