我遇到了一个小路障。英语很差,难以表达
我想修改正文中的Request并发送两个连续的Request
原创内容:
POST http://www.text.com/next?cyt=1 is
HTTP/1.1
Host: www.text.com
User-Agent: Million/1.0.0
Content-Length: 58
Accept: * / *
Accept-Encoding: gzip
Accept-Language:
Content-Type: application / x-www-form-urlencoded
Cookie: S = hveisf76n2lrnpvbeng8ivrat6
Connection: keep-alive
Connection: keep-alive
S = hveisf76n2lrnpvbeng8ivrat6 & step = ashf87afs0a2e4
尝试修改Body并发送到:
S = hveisf76n2lrnpvbeng8ivrat6 & step = qarker11s77ar
另一次尝试修改Body并发送到:
S = hveisf76n2lrnpvbeng8ivrat6 & step = qarker22s88ar
请求已发送两次修改后的正文
我尝试做代码:
static function OnBeforeRequest(oSession: Session)
{
if(oSession.uriContains("http://www.text.com/next?cyt=1"))
{
var strBody=oSession.GetRequestBodyAsString();
strBody=strBody.replace("step=ashf87afs0a2e4","step=qarker11s77ar");
oSession.utilSetRequestBody(strBody);
var strBody1=oSession.GetRequestBodyAsString();
strBody1=strBody.replace("step=qarker11s77ar","step=qarker22s88ar");
oSession.utilSetRequestBody(strBody1);
}
}
出现的问题是:
S = hveisf76n2lrnpvbeng8ivrat6& step = qarker11s77ar
传输成功,但
S = hveisf76n2lrnpvbeng8ivrat6& step = qarker22s88ar
并且无法发送,如何解决这个问题?谢谢。
答案 0 :(得分:1)
static function OnBeforeRequest(oSession: Session)
{
if(oSession.uriContains("http://www.text.com/next?cyt=1"))
{
var strBody=oSession.GetRequestBodyAsString();
strBody=strBody.replace("step=ashf87afs0a2e4","step=qarker11s77ar");
strBody=strBody.replace("step=qarker11s77ar","step=qarker22s88ar");
oSession.utilSetRequestBody(strBody);
}
}