如何通过http接口使用f12b实现批量提交链接
这里我们分别叙述了如何在浏览器直接使用此接口,以及通过java和python如何使用此接口。
一、以浏览器为例
(一)提交一个指令
serverURL=http://120.79.247.23/f12Browser/http?cmd=requestACommand #指令提交地址
username=test #测试专用用户名
password=123456 #测试专用密码
targetURL=http://www.baidu.com #你的目标url,这个可以修改为你指定的url
commandVersion=local_and_server #固定值
commandAction=none #固定值
1 请求链接=serverURL+username+password+targetURL+commandVersion+commandAction
如“http://120.79.247.23/f12Browser/http?cmd=requestACommand&username=test&password=123456&targetURL=http://www.baidu.com&commandVersion=local_and_server&commandAction=none”
2 将上述链接复制并黏贴至浏览器运行,会得到下面的字符串,表明指令提交成功。其中commandID为系统分配给你的唯一标识,后续操作需要通过该ID实现。
<status>success</status><commandID>19</commandID>
若status不为success,则返回格式为
<status>error</status><msg>异常信息</msg>
(二) 查询执行情况
serverURL=http://120.79.247.23/f12Browser/http?cmd=quaryACommand #指令查询地址
username=test #测试专用用户名
password=123456 #测试专用密码
commandID=19 #指令唯一标识
1 请求链接=serverURL+username+password+commandID
如“http://120.79.247.23/f12Browser/http?cmd=quaryACommand&username=test&password=123456&commandID=19”
2 将上述链接复制到浏览器执行,会得到下面的字符串。其中commandStatus表明了当前指令的执行情况,finished表明该指令已执行完成,可以向服务器请求执行结果
<status>success</status>
<commandID>19</commandID>
<commandVersion>local_and_server</commandVersion>
<targetURL>http://www.baidu.com</targetURL>
<commandAction>none<commandAction/>
<commandStatus>finished</commandStatus>
<createrID>1</createrID>
<createTime>2018-06-11 14:25:10.0</createTime>
<updateTime>2018-06-11 14:25:25.0</updateTime>
3 若指令还未开始还行,则commandStatus=create,未执行完成,则commandStatus=assigned
4 若查询过程中出现异常,返回格式为:
<status>error</status><msg>异常信息</msg>
(三)获取执行结果
在浏览器中有两种方式获取结果,一是通过接口请求结果,另一种是可以直接下载结果文件。
1 通过接口请求结果
http://120.79.247.23/f12Browser/http?cmd=getAFileContent&username=test&password=123456&commandID=19
正确的结果形式:
<status>success</status><fileContent>URL对应的HTML源码</fileContent>
若发生异常:
<status>error</status><msg>异常信息</msg>
2 直接下载结果文件
http://120.79.247.23/f12Browser/http?cmd=downloadAFile&username=test&password=123456&commandID=19
二、以java为例
这里需要用到webdriver3.7的环境
https://share.weiyun.com/5DCfA1a
(一)提交一个指令
public static void main(String[] args) {
try{
//1 提交指令
String requestCommandURL = "http://120.79.247.23/f12Browser/http?cmd=requestACommand";
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost=new HttpPost(requestCommandURL);
List<BasicNameValuePair> params=new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("username", "test"));
params.add(new BasicNameValuePair("password", "123456"));
params.add(new BasicNameValuePair("targetURL", "http://www.baidu.com"));
params.add(new BasicNameValuePair("commandVersion", "local_and_server"));
params.add(new BasicNameValuePair("commandAction", "none"));
httpPost.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
if(entity==null){
System.out.println("error entity==null");
client.close();
return;
}
String results = EntityUtils.toString(entity, "UTF-8");
System.out.println("results="+results);
client.close();
return;
}catch(Exception e){
e.printStackTrace();
return;
}
}
正确执行的话应该能得到如下结果:
<status>success</status><commandID>19</commandID>
若status不为success,则返回格式为
<status>error</status><msg>异常信息</msg>
(二)查询执行情况
public static void main(String[] args) {
try{
//2 查询指令执行状态
String requestCommandURL = "http://120.79.247.23/f12Browser/http?cmd=quaryACommand";
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost=new HttpPost(requestCommandURL);
List<BasicNameValuePair> params=new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("username", "test"));
params.add(new BasicNameValuePair("password", "123456"));
params.add(new BasicNameValuePair("commandID", "19"));
httpPost.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
if(entity==null){
System.out.println("error entity==null");
client.close();
return;
}
String results = EntityUtils.toString(entity, "UTF-8");
System.out.println("results="+results);
client.close();
return;
}catch(Exception e){
e.printStackTrace();
return;
}
//3 获取执行结果
}
正确执行的话应该能得到如下结果:
<status>success</status>
<commandID>19</commandID>
<commandVersion>local_and_server</commandVersion>
<targetURL>http://www.baidu.com</targetURL>
<commandAction>none<commandAction/>
<commandStatus>finished</commandStatus>
<createrID>1</createrID>
<createTime>2018-06-11 14:25:10.0</createTime>
<updateTime>2018-06-11 14:25:25.0</updateTime>
若指令还未开始还行,则commandStatus=create,未执行完成,则commandStatus=assigned
若查询过程中出现异常,返回格式为:
<status>error</status><msg>异常信息</msg>
(三)获取执行结果
public static void main(String[] args) {
try{
//3 获取执行结果
String requestCommandURL = "http://120.79.247.23/f12Browser/http?cmd=getAFileContent";
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost=new HttpPost(requestCommandURL);
List<BasicNameValuePair> params=new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("username", "test"));
params.add(new BasicNameValuePair("password", "123456"));
params.add(new BasicNameValuePair("commandID", "19"));
httpPost.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
if(entity==null){
System.out.println("error entity==null");
client.close();
return;
}
String results = EntityUtils.toString(entity, "UTF-8");
System.out.println("results="+results);
client.close();
return;
}catch(Exception e){
e.printStackTrace();
return;
}
}
正确的结果形式:
<status>success</status><fileContent>URL对应的HTML源码</fileContent>
若发生异常:
<status>error</status><msg>异常信息</msg>
三、以python为例
(一)提交一个指令
#!/usr/bin/python
import urllib.request
import urllib.parse post_data = urllib.parse.urlencode({
'cmd':'requestACommand',
'targetURL':'http://www.baidu.com',
'username':'test',
'password':'',
'commandVersion':'local_and_server',
'commandAction':'none'
}).encode('utf-8')
requrl = "http://120.79.247.23/f12Browser/http"
req = urllib.request.Request(url = requrl, data = post_data)
print(urllib.request.urlopen(req).read().decode('utf-8'))
正确执行的话应该能得到如下结果:
<status>success</status><commandID>19</commandID>
若status不为success,则返回格式为
<status>error</status><msg>异常信息</msg>
(二)查询执行情况
#!/usr/bin/python
import urllib.request
import urllib.parse post_data = urllib.parse.urlencode({
'cmd':'quaryACommand',
'username':'test',
'password':'',
'commandID':''
}).encode('utf-8')
requrl = "http://120.79.247.23/f12Browser/http"
req = urllib.request.Request(url = requrl, data = post_data)
print(urllib.request.urlopen(req).read().decode('utf-8'))
正确执行的话应该能得到如下结果:
<status>success</status>
<commandID>19</commandID>
<commandVersion>local_and_server</commandVersion>
<targetURL>http://www.baidu.com</targetURL>
<commandAction>none<commandAction/>
<commandStatus>finished</commandStatus>
<createrID>1</createrID>
<createTime>2018-06-11 14:25:10.0</createTime>
<updateTime>2018-06-11 14:25:25.0</updateTime>
若指令还未开始还行,则commandStatus=create,未执行完成,则commandStatus=assigned
若查询过程中出现异常,返回格式为:
<status>error</status><msg>异常信息</msg>
(三)获取执行结果
#!/usr/bin/python
import urllib.request
import urllib.parse post_data = urllib.parse.urlencode({
'cmd':'getAFileContent',
'username':'test',
'password':'',
'commandID':''
}).encode('utf-8')
requrl = "http://120.79.247.23/f12Browser/http"
req = urllib.request.Request(url = requrl, data = post_data)
print(urllib.request.urlopen(req).read().decode('utf-8'))
正确的结果形式:
<status>success</status><fileContent>URL对应的HTML源码</fileContent>
若发生异常:
<status>error</status><msg>异常信息</msg>
如何通过http接口使用f12b实现批量提交链接的更多相关文章
- js 批量提交数据
// 批量提交数据 let pageSize = 100, total = dataTmp.length, list = dataTmp let totalPage = Math.ceil(total ...
- MyBatis 通过 BATCH 批量提交
本文由 简悦 SimpRead 转码, 原文地址 https://www.jb51.net/article/153382.htm 很多人在用 MyBatis 或者 通用 Mapper 时,经常会问有没 ...
- php中bindValue的批量提交sql语句
php预编译sql语句,可以批量提交sql,也可以实现防注入 <?php $dsn='mysql:host=127.0.0.1;port=3306;dbname=bisai'; $usernam ...
- git批量删除文件和批量提交
1. 单个删除文件: ① 通常直接在文件管理器中把没用的文件删了,或者用rm命令删了:(可选操作,可直接执行②删除) $ rm test.txt ② 确实要从版本库中删除该文件,那就用命令git rm ...
- Asp.Net Mvc表单提交(批量提交)
Asp.Net Mvc中Action的参数可以自动接收和反序列化form表单的值, 采用form表单提交 name=value类型,只要Action参数的变量名和input的name相同就行 html ...
- SQL批量提交修改业务
把你需要批量提交修改的东西在内存中修改完毕 然后执行以下代码 SqlConnection conn = new SqlConnection(ConnectionString);SqlDataAdapt ...
- Ext.Ajax.request批量提交表单
介绍一下批量提交grid中数据的问题 js文件中的提交方法如下: listeners: { click: function btnClick(button) { var win = button.up ...
- TopJUI通过简单的代码实现复杂的批量提交功能
业务系统的批量提交是常用的操作功能,使用传统的EasyUI开发时需要写不少代码才能实现,该功能在TopJUI中是如何实现的呢?本篇我们将通过简单的代码,把批量操作的具体实现分享给大家参考. <a ...
- 【INSERT】逐行提交、批量提交及极限提速方法
在Oracle数据库中,不是提交越频繁越好.恰恰相反,批量提交可以得到更好的性能.这篇文章给大家简单展示一下在Oracle数据库中逐行提交于批量提交两者之间的性能差别.最后再给出一种可以极大改变性能的 ...
随机推荐
- Java sql server数据库连接成功
import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.sql ...
- Mysql闪回技术之 binlog2sql
1.下载 https://github.com/danfengcao/binlog2sql http://rpmfind.net Search: python-pip pip 是一个Python包管理 ...
- JAVA 虚拟机内存
1.普通java应用程序,使用java命令运行, java -Xms1024m -Xmx1024m -XX:MaxNewSize=256m -XX:MaxPermSize=256m -jar 2.t ...
- OpenCV学习笔记一:OpenCV概览与配置编译
一,OpenCV OpenCV官方网站:http://opencv.org/ OpenCV目前最新代码库地址:https://github.com/itseez/opencv 二,简介: OpenC ...
- 正则表达式初识,re模块
作业收藏 # 3.reversed和sorted和list列表类型内置的sort.reverse有什么区别? #reversed 的返回值是一个迭代器并不会直接修改原列表 sorted的返回值是生成一 ...
- shell编程实战总结
最近复习一下shell,顺便高级进阶一下,之前写脚本能简单尽量简单来,发现好多高深的东西还是没有理解,因此在这里记录一下整个过程并做相应的总结. 通过上代码的方式来介绍,后续可能会调整相应的排版 1. ...
- redis 有序集合数据结构实现 skiplist
Redis使用跳跃表作为有序集合键的的底层实现,如果一个有序集合包含的元素数量比较多,又或者有序集合中元素的成员是比较长的字符串时Redis就会使用跳跃表 来作为有序集合键的底层实现 Redis只在两 ...
- codevs1044 拦截导弹==洛谷 P1020 导弹拦截
P1020 导弹拦截 题目描述 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度.某天 ...
- Cocos2d-x Lua中实例:帧动画使用
下面我们通过一个实例介绍一下帧动画的使用,这个实例如下图所示,点击Go按钮开始播放动画,这时候播放按钮标题变为Stop,点击Stop按钮可以停止播放动画. 帧动画实例 下面我们再看看具体的程序代码,首 ...
- php7/etc/php-fpm.d 配置
php7/etc/php-fpm.d/www.conf nginx php-fpm 高并发优化 - 日记本的回忆 - 博客园 https://www.cnblogs.com/cocoliu/p/856 ...