网页不能批量操作?自己来!
背景
有时候有些网页并不支持批量操作,但是写代码要抓cookie这些非常繁琐,最快实现目标则是搞一段js代码,直接浏览器跑
为了代码更好的排版,可在DevTools的:源代码->片段(找不到可以拉开) -> 新增片段 来进行粘贴js执行
实现
浏览器console批量POST方式
// POST方法
function send_request(url, data){
var params = data;
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function (e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
console.log(xhr.responseText);
} else {
console.error(xhr.statusText);
}
}
};
xhr.onerror = function (e) {
console.error(xhr.statusText);
};
xhr.send(JSON.stringify(params));
}
// 处理Post数据
let data = 'AAAA;BBBB'
data = data.split(';');
const params_list = [];
data.forEach((row) => {
tpl = {
"src_mod":"DFDFDFDFDF",
"src_id":"",
"dst_mod":row,
"dst_id":"",
"port":"3308",
"ptc":"TCP",
"type":"create",
"auth_type":19,
"auth_params":"DDDDD",
"netauth":"0",
"is_db":1
}
params_list.push(tpl);
})
// 实际POST数据
send_request("https://xxxx.com/interface/confirm", params_list)
循环,拿结果方式
// POST方法
function send_request(url, data, callback){
var params = data;
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function (e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
callback(xhr.responseText)
} else {
console.error(xhr.statusText);
}
}
};
xhr.onerror = function (e) {
console.error(xhr.statusText);
};
xhr.send(JSON.stringify(params));
}
// 处理Post数据
let data = 'DDDDDDD'
data = data.split(';');
data.forEach((row) => {
tpl = {
"timestamp":1668512485300,
"serviceName":"DSDSDSDS",
"apiUrl":"/sdsdsd/sdsdsd",
"traceId":"SDDFDFDFDFDFDF",
"body":{
"sort":"modify_time",
"module_name":"",
"sort_order":2,
"search_type":1,
"index_page":1,
"page_size":10,
"var_type":"",
"oper_name":"",
"path_name":row,
"module_list":[],
"busi_space_name":"default",
"domainState":1,
"bIsOpsAdmin":true
}
}
// 实际POST数据
send_request("https://XXXXX.com/AAAA", tpl, (data)=>{
const _data = JSON.parse(data)
_data.body.variable_info_list.forEach((_row) => {
_row.rule_list.forEach((_s_row) => {
if (_s_row.rule_type === 5) {
console.log(_s_row.var_full_name)
}
})
})
})
})
畅享移动传奇:独家私服手游,玩转激情岁月!:https://501h.com/jinbi/2024-08-09/26720.html
如何成功开通传奇私服游戏?:https://501h.com/lianji/15312.html
你的文章充满了创意,真是让人惊喜。 https://www.yonboz.com/video/15135.html
你的文章内容非常精彩,让人回味无穷。 https://www.yonboz.com/video/75352.html