https://docs.telerik.com/fiddler/Generate-Traffic/Tasks/SearchSequentialPages
static function OnBeforeResponse(oSession: Session) {
// 状态码为 502、500、404 的发钉钉提醒
var errorCodes = "502500404";
var responseCode = oSession.responseCode.ToString()
var pattern = new RegExp(responseCode);
if(oSession.hostname.Contains("xieboke.net") && pattern.test(errorCodes) ){
var key="";
var request_body = oSession.GetRequestBodyAsString().replace(/"/g,"'");
var content ="[" + oSession.responseCode + "]" + oSession.oRequest.headers + "\n" + request_body;
//MessageBox.Show(content)
//钉钉机器人地址
var dingding_hook = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxx"
var user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
var body = '{"msgtype": "text","text": {"content": "' + content + '"}}'
var body_length = body.length + 4;
//var rg = "GET https://xieboke.net/ HTTP/1.1\r\nUser-Agent:" + user_agent + "\r\nHost: xieboke.net\r\nReferer:https://xieboke.net/\r\n\r\n";
var method = "POST";
var myUrl = dingding_hook;
var url = myUrl;
var protocol = "HTTP/1.1";
var raw="";
raw += method + " " + url + " " + protocol + "\r\n";
raw += "User-Agent:" + user_agent + "\r\n";
raw += "Content-Length:" + body_length + "\r\n";
raw += "Content-Type:application/json" + "\r\n\r\n";
raw += "\r\n" + body + "\r\n\r\n";
//MessageBox.Show(raw)
try{
// Make a recursive HTTP request for the next item.
// 接口请求信息发送到钉钉
FiddlerObject.utilIssueRequest(raw);
}
catch(e){
MessageBox.Show(e.ToString());
}
}
}
因为 post 请求时,缺少 csrf 验证,被 Django 拒了(WARNING Forbidden (CSRF cookie not set.): /)