很好,选了这么简洁的例子.
obj提供的http过程每次都会打开并关闭会话ID,所以很多严格要求的网站会直接拒绝,但此网站应该不会。
这里提供一下我的例子,需要用到我的自定义UDF, winhttp_getrespond,64楼。
代码:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinHttp_GetRespondNew.au3>
#include <array.au3>
$MyOpen=_WinHttpOpen()
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("传智教育网站批量注册", 623, 442, 192, 124)
$Pic1 = GUICtrlCreatePic("", 224, 16, 40, 10)
$Input1 = GUICtrlCreateInput("1223", 232, 112, 121, 21)
$Label1 = GUICtrlCreateLabel("用户名", 152, 112, 40, 17)
$Label2 = GUICtrlCreateLabel("密码", 152, 160, 28, 17)
$Button1 = GUICtrlCreateButton("刷新", 392, 32, 97, 49)
$Input2 = GUICtrlCreateInput("1223", 232, 160, 121, 21)
$Label3 = GUICtrlCreateLabel("邮箱", 152, 224, 28, 17)
$Input3 = GUICtrlCreateInput("jj@126.com", 232, 224, 121, 21)
$Button2 = GUICtrlCreateButton("注册", 400, 208, 91, 41)
$Input4 = GUICtrlCreateInput("", 512, 40, 97, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $ASPSESSIONIDCSCDARTQ
$rContext=_WinHTTP_GetRespond($MyOpen,"http://xmczjy.com/MemberReg.asp",4 + 2,50000,"","webim_login_status=0")
If @error Then MsgBox(0,@error,"出错了")
;~ MsgBox(0,$rContext[3],$rContext[6])
;~ MsgBox(0,"内容",BinaryToString($rContext[0]))
$ASPSESSIONIDCSCDARTQ = StringRegExpReplace($rContext[3],"(ASPSESSIONIDCSCDARTQ=.*?);.*","$1")
_Get_Code()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_WinHttpCloseHandle($MyOpen)
Exit
Case $Button1
_Get_Code()
Case $Button2
$Context = "Item1="&GUICtrlRead($Input1)&"&Item2="&GUICtrlRead($Input2)&"&fItem2="&GUICtrlRead($Input2)&"&Item3=&Item4=&Item5="&GUICtrlRead($input3) &"&Code="&GUICtrlRead($input4)&"&Submit=+%D7%A2%B2%E1+"
$rContext=_WinHTTP_GetRespond($MyOpen,"http://xmczjy.com/MemberReg.asp?Action=Reg",1 + 4 + 2 + 8,50000,$Context,$ASPSESSIONIDCSCDARTQ,"Content-Type: application/x-www-form-urlencoded")
If @error Then MsgBox(0,@error,"出错了")
MsgBox(0,$rContext[3],$rContext[6])
MsgBox(0,"跳转即成功",BinaryToString($rContext[0]))
Sleep(200)
$rContext=_WinHTTP_GetRespond($MyOpen,'http://xmczjy.com/Member.asp?Action=Logout',0 ,50000,"",$ASPSESSIONIDCSCDARTQ) ;注销,方便再次注册
EndSwitch
WEnd
Func _Get_Code()
GUICtrlSetData($input1,Random(10000,99999,1)&Random(10000,99999,1))
GUICtrlSetData($input2,"1223"&Random(1000,9999,1))
GUICtrlSetData($input3,Random(1000,9999,1)&"jj@126.com")
$rContext=_WinHTTP_GetRespond($MyOpen,"http://xmczjy.com/Include/Code.asp?"&@SEC ,4 + 2 ,50000,"",$ASPSESSIONIDCSCDARTQ)
If @error Then Return MsgBox(0,@error,"出错了")
$CodeFile = FileOpen(@ScriptDir & "\code.bmp",10)
FileWrite($CodeFile,Binary($rContext[0]))
FileClose($CodeFile)
GUICtrlSetImage($Pic1,@ScriptDir & "\code.bmp")
EndFunc
代码及编译程序打包下载。
|