post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示

Re: post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示

Post by wzdg » 20 Jul 2016, 10:13

tmplinshi wrote:另外建议用 Tab3 控件(需要 AHK V1.1.24.00+)。你没发现 Tab2 控件,当你从第一个标签切换到第二个标签时,网页有时显示不全吗?Tab3 控件已经修复了这个问题。
哎,想起来了,因为默认4.6-2.1=2.500000,都是这样显示着了,所以那天晚上最后查了一下帮助处理了一下,没想到问题就出在这儿了啊,谢谢你了,几个关于网页操控的帮助帖都是你帮助我的,太感谢你了

Re: post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示

Post by tmplinshi » 20 Jul 2016, 09:47

另外建议用 Tab3 控件(需要 AHK V1.1.24.00+)。你没发现 Tab2 控件,当你从第一个标签切换到第二个标签时,网页有时显示不全吗?Tab3 控件已经修复了这个问题。

Re: post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示

Post by tmplinshi » 20 Jul 2016, 09:44

我抓包看了下,抓包工具中看到的 Post 数据与代码中的不一致。所以就是 POST 请求出错了。

而那个 POST 代码目测并没有错误,我单独复制出来到另一个脚本执行了下,POST 数据能正常发送。所以就是你脚本中其他地方造成了。

然后看到代码开头的SetFormat, float, 6.2,感觉比较可疑,注释掉后果然就正常了。

Re: post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示

Post by wzdg » 20 Jul 2016, 07:31

tmplinshi wrote:我猜是因为网站更新了。建议重新抓包对比。
我7月18日晚上修改好的,还生成了两条数据,能正常使用,7.19日就不能用了,昨天到今天查了好多次,也没找出原因,也抓包分析过了,也没找出原因,实在是没辙了,奇了怪了

Re: post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示

Post by tmplinshi » 20 Jul 2016, 03:08

我猜是因为网站更新了。建议重新抓包对比。

post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示

Post by wzdg » 20 Jul 2016, 01:49

前天晚上刚写完的脚本能正常使用,格式化了一下脚本保存了文件,到了第二天之后就不能用了,到今天也一直不能用,错误就是post数据给网页的时候弹出Your request has bad syntax or is inherently impossible to satisfy的错误提示,一直找不到原因,也找不到解决办法,IE能正常打开这个网页,特来论坛求助大神的帮忙,谢谢了。附上脚本

Code: Select all

#SingleInstance Force
SetWorkingDir %A_ScriptDir%
SetFormat, float, 6.2                    ;;浮点数默认为总宽度.小数位数 = 0.6,此处为设置小数位为2位
#Include Lib\HTTPRequest.ahk
global lv, wb,date1,date2,yema,zongshu,ioData,content_text

Gui Font, s12 Bold
Gui Add, Tab2, -Background x-3 y2 w1011 h615, 主界面|浏览器   ;;多tab界面的用法,先指定一个tab,其后添加的控件都在这个tab下,如下面的提供帮助、得到帮助这些
Gui Font
	Gui Tab, 1
	Gui Font, s10

	Gui Add, Text, x12 y30 w59 h23 +0x200, 提供帮助
	Gui Add, Edit, x69  y30 w120 h21 vin
	Gui Add, Text, x215 y30  w52 h23 +0x200, 得到帮助
	Gui Add, Edit, x280  y30 w120 h21 vout
	Gui Add, Button, x420 y30 w90 h23 g_search, 获取数据                    ;;用到了按钮的g标签事件,即点击按钮后出发_search标签
	Gui Add, Edit, x538  y30 w120 h21 vsousuo

	Gui Add, Text, x+15 y30  w52 h23 +0x200, 开始时间
	Gui Add, Edit, x+15  y30 w80 h21 vdate1 ,2016-07-05
	Gui Add, Text, x+15 y30  w52 h23 +0x200, 结束时间
	Gui Add, Edit, x+15 y30 w80 h21 vdate2  ,2016-07-18

	Gui Add, ListView, x11 y+10 w980 h520 Grid, 序号|资产|时间|入账金额|描述
	Gui Font, s11 Bold cRed
	Gui Add, StatusBar, vzhuangtai x0 y610 w667 h22, 信息:
	Gui Font

		Gui Tab, 2                    ;;第二个tab标签
		Gui Add, ActiveX, x6 y30 w987 h555 vwb, Shell.Explorer
		Gui Show, w1002 h612,
		Sleep 100
		qbao.打开登录页面()
		Sleep 500
		return


_search:
	Gui Submit,NoHide
	global guding, fudong, zongshouru
	LV_Delete()
	qbao.等待登录成功()
	qbao.获取所查的宝券()
	Sleep 500
	MsgBox %ioData%
	MsgBox % json_toobj(ioData).pageSum
	Loop % json_toobj(ioData).pageSum                    ;;总的页码数
	{
		载入结果( qbao.获取所查的宝券(A_Index) )
		FileAppend, %ioData%  ,%A_Desktop%\第%A_Index%页码
	}
	LV_ModifyCol(1, "CEnter 70")				;中间
	LV_ModifyCol(2, "CEnter 120")			;左边对齐
	LV_ModifyCol(3, "CEnter 180")
	LV_ModifyCol(4, " CEnter 120")
	GuiControl, , zhuangtai, % "签到总金额:" . zongshouru "或者是" . guding+fudong ","  a_Space  "浮动收益总额是:" . fudong  "固定收益总金额是:" guding
	FileAppend,%content_text% , %A_Desktop%\%date1%--%date2%之间的收入数据.txt
return

GuiDropFiles:                         ;;拖拽文件到gui窗口,A_GuiEvent变量即为拖拽入的文件路径
	Gui Submit,NoHide
	LV_Delete()
	FileRead,text,%A_GuiEvent%
	search_to_display(text)
return


search_to_display(lines)
{
	guding:=0
	fudong:=0
	Gui Submit, nohide
	LV_Delete() ; 清理不掉,第二次加载后,都成了重复的了,不知道怎么处理

	Loop, Parse, lines, `n, `r                    ;;一行一行的解析数据
	{
		if % A_LoopField=                    ;;空行直接跳过
			continue
		else
		{
			text := StrSplit(A_LoopField, "`n")
			GuiControl, -Redraw, listview ; 重新启用重绘 (上面把它禁用了)
			for k,v in text
			{
				hangshu:=LV_GetCount()      ;;计算出已有lv的总行数,方便下次使用函数的时候把行数叠加上去,要不会出现,1,2,3,4,5,1,2,3,4,这样的行数
				list := StrSplit(v, "`t")                    ;;以制表符为记号解析每一行的数据
				LV_Add("", hangshu+A_Index, list[1], list[2], list[3],list[4])                    ;;把解析出来的数据写入lv
				if % list[4]="固定收益"
					guding+=list[3]
				else
					fudong+=list[3]
			}
			GuiControl, +Redraw, listview ; 重新启用重绘 (上面把它禁用了)
		}
	}
	LV_ModifyCol(1, "CEnter 70")				;中间
	LV_ModifyCol(2, "CEnter 120")			;左边对齐
	LV_ModifyCol(3, "CEnter 180")
	LV_ModifyCol(4, " CEnter 120")
	GuiControl, , zhuangtai, % "签到总金额:" . zongshouru "或者是" . guding+fudong ","  a_Space  "浮动收益总额是:" . fudong  "固定收益总金额是:" guding
	FileAppend,%content_text% , %A_Desktop%\%date1%--%date2%之间的收入数据.txt
}


载入结果(obj_result) {                    ;;把obj数据分解加载到listview中
    count:=0
    guding:=0
    fudong:=0
	hangshu:=LV_GetCount()
	;~ for i, row in obj_result.data
	data:=json_toobj(obj_result.data)
	for i, row in data
	{
		if % row.workflowDesc="签到浮动收益"                    ;;workflowDesc : "签到固定收益"
		{
			miaoshu:="浮动收益"
			fudong+=row.inAmount
			count++
		}
		else if  % row.workflowDesc="签到固定收益"
		{
			miaoshu:="固定收益"
			guding+=row.inAmount
			count++
		}
		else
			continue
		LV_Add("", hangshu+count,row.balance,row.createTime, row.inAmount,miaoshu)
		content_text .=row.balance "`t" row.createTime "`t" row.inAmount "`t" miaoshu "`n"  ;;lv的各列之间用tab标识,各行之间用两次回车标识,方便后面取值
	}
	zongshouru:=guding+fudong
	return  fudong  guding  zongshouru
}

GuiEscape:
GuiClose:
	ExitApp


/*  postdate数据
startTime:2016-07-05
endTime:2016-07-18
type:0
role:1                    ;;有时候是1有时候是3,不知道怎么做到智能化
page:1
size:10
*/

class qbao {
	
打开登录页面() {                    ;;软件自动打开登录页面,并填入账户和密码,等待用户填入验证码即可登录
	wb.silent := true
	wb.navigate("https://passport.qbao.com/cas/qianbaoLogin?service=http://www.qbao.com/?ticket=ST-9671737-3c7yVUiwicZQYn1M556s-cas")
	Loop {
		Sleep 100
	} until (wb.document.getElementById("submitForm").value="登录")                    ;;通过判断按钮是否出现来判断网页是否加载完成
	Sleep 300
	;设置新属性值
	wb.document.getElementById("username").value:="18434360249"                    ;;填入账户
	wb.document.getElementById("password").value:="gqr6851826"                              ;;填入密码
	}

等待登录成功() {                    ;;等待登录成功}
	Loop {
		Sleep, 200
	} until (wb.document.getElementById("ut9"))                    ;;通过判断这个id出现与否来判断是否登录成功
}

获取所查的宝券(page = 1) {                    ;;通过post方法获取个人资产明细数据
	url := "http://payportal.qbao.com/assetDetail/assetPersonalResult.html"
	ref := "http://payportal.qbao.com/assetDetail/assetDetail.html"
	postData := "startTime=" date1 "&endTime=" date2  "&type=0&role=3" "&page=" page "&size=10"	;page是第几页,date1是开始日期,date2是截止日期,size是每一页的容量
	while, !HttpRequest(url, ioData := postData, ioHdr := Headers(ref), "Charset: UTF-8") {
	Sleep, 1000
}
	MsgBox % ioData
;~ FileAppend, %ioData% ,%A_Desktop%\第%page%页码                    ;;把每一页的json数据单独写入各自记事本
return json_toobj(ioData)                     ;;把json数据转换为obj数据并返回给函数
}

hdr(referer = "") {
	return "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" . "`n"
	. "Referer: " referer
}
}

	
Headers(referer = "")
{
	global userAgent
	if !userAgent				;如果没指定userAgent,则指定给他userAgent为IE8   ,userAgent和Referer一般复制浏览器里面得到的数据就行
		userAgent := "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)"   ;IE8的默认userAgent;
	Headers =
	( LTRIM
		Referer: %referer%
		User-Agent: %userAgent%
	)
	return Headers
}

json_toobj(str){
	quot := """"
	ws := "`t`n`r " Chr(160)
	obj := {}
	objs := []
	keys := []
	isarrays := []
	literals := []
	y := nest := 0
	StringGetPos, z, str, %quot%
	while !ErrorLevel
	{
		StringGetPos, x, str, %quot%,, % z + 1
		while !ErrorLevel
		{
			StringMid, key, str, z + 2, x - z - 1
			StringReplace, key, key, \\, \u005C, A
			if SubStr( key, 0 ) != "\"
				break
			StringGetPos, x, str, %quot%,, % x + 1
		}
		str := ( z ? SubStr( str, 1, z ) : "" ) quot SubStr( str, x + 2 )
		StringReplace, key, key, \%quot%, %quot%, A
		StringReplace, key, key, \b, % Chr(08), A
		StringReplace, key, key, \t, % A_Tab, A
		StringReplace, key, key, \n, `n, A
		StringReplace, key, key, \f, % Chr(12), A
		StringReplace, key, key, \r, `r, A
		StringReplace, key, key, \/, /, A
		while y := InStr( key, "\u", 0, y + 1 )
		if ( A_IsUnicode || Abs( "0x" SubStr( key, y + 2, 4 ) ) < 0x100 )
			key := ( y = 1 ? "" : SubStr( key, 1, y - 1 ) ) Chr( "0x" SubStr( key, y + 2, 4 ) ) SubStr( key, y + 6 )
		literals.Insert(key)
		StringGetPos, z, str, %quot%,, % z + 1
	}
	key := isarray := 1
	Loop Parse, str, % "]}"
	{
		StringReplace, str, A_LoopField, [, [], A
		Loop Parse, str, % "[{"
		{
			if ( A_Index != 1 )
			{
				objs.Insert( obj )
				isarrays.Insert( isarray )
				keys.Insert( key )
				obj := {}
				isarray := key := Asc( A_LoopField ) = 93
			}
			if ( isarray )
			{
				Loop Parse, A_LoopField, `,, % ws "]"
					if ( A_LoopField != "" )
						obj[key++] := A_LoopField = quot ? literals.Remove(1) : A_LoopField
			}
			else
			{
				Loop Parse, A_LoopField, `,
					Loop Parse, A_LoopField, :, % ws
						if ( A_Index = 1 )
							key := A_LoopField = quot ? literals.Remove(1) : A_LoopField
						else if ( A_Index = 2 && A_LoopField != "" )
							obj[key] := A_LoopField = quot ? literals.Remove(1) : A_LoopField
			}
			nest += A_Index > 1
		}
		if !--nest
			break
		pbj := obj
		obj := objs.Remove()
		obj[key := keys.Remove()] := pbj
		if ( isarray := isarrays.Remove() )
			key++
	}
	return obj
}
Attachments
1.png
1.png (10.04 KiB) Viewed 5157 times

Top