|
发表于 2011-5-22 08:33:57
|
显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
Global $OEvent = ObjEvent("AutoIt.Error", "MyErrFunc")
Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
Global $YHM,$mm
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 203, 203, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Input1 = GUICtrlCreateInput("", 72, 24, 129, 21)
$Label1 = GUICtrlCreateLabel("用户名:", 24, 24, 43, 17)
$Label2 = GUICtrlCreateLabel("密 码:", 24, 51, 43, 17)
$Input2 = GUICtrlCreateInput("", 72, 48, 129, 21)
$Button1 = GUICtrlCreateButton("Button1", 32, 104, 161, 33)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func _getString($sting,$bz)
$prcs=StringSplit($sting,$bz,1)
$prc=StringSplit($prcs[2],";")
Return $prc[1]
EndFunc
Func Button1Click()
$YHM=GUICtrlRead($Input1)
$mm=GUICtrlRead($Input2)
$oHTTP.SetTimeouts(15000, 15000, 15000, 15000) ;设置超时
$oHTTP.Option(4) = 13056
$oHTTP.Option(6) = True ;为True时,当请求的页面中有跳转时,抓取跳转页面信息.False相反不抓取
$oHTTP.open("POST","http://passport.51.com/login.5p",True)
$oHTTP.setRequestHeader("Accept","application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*")
$oHTTP.setRequestHeader("Accept-Encoding","gzip, deflate")
$oHTTP.setRequestHeader("Accept-Language","zh-cn")
$oHTTP.setRequestHeader("Cache-Control","no-cache")
;$oHTTP.setRequestHeader("Cookie", "string") ;先设置一个cookie,防止出错,见官方文档
;$oHTTP.setRequestHeader("Cookie","passport_login_errorcode=; "& $PCCOOKIE)
$oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$oHTTP.setRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
$oHTTP.send("gourl=http://my.51.com&passport_51_password=" & $mm & "&passport_51_user=" & $YHM & "&passport_cookie_login=0")
$oHTTP.WaitForResponse
;$ResponseText = BinaryToString ( $oHTTP.responseBody,4 )
;FileWriteLine(@ScriptDir&"\data.HTML",$ResponseText)
Sleep(100)
$oHTTP.open("GET","http://my.51.com/new.index.php",True)
$oHTTP.setRequestHeader("Accept","application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*")
$oHTTP.setRequestHeader("Accept-Encoding","gzip, deflate")
$oHTTP.setRequestHeader("Accept-Language","zh-cn")
$oHTTP.setRequestHeader("Cache-Control","no-cache")
$oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$oHTTP.setRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
$oHTTP.send("")
$oHTTP.WaitForResponse
;$ResponseText = BinaryToString ( $oHTTP.responseBody,4 )
$ResponseText = $oHTTP.ResponseText
FileWriteLine(@ScriptDir&"\data.txt",$ResponseText)
EndFunc
Func Form1Close()
Exit
EndFunc
Func MyErrFunc()
EndFunc |
评分
-
查看全部评分
|