#include <WinHttp_GetRespond.au3>
#include <array.au3>
$MyOpen=_WinHttpOpen()
$TelNumber = InputBox("请输入用户名","请输入用户名")
$rContext=_WinHTTP_GetRespond($MyOpen,"http://mail.10086.cn/Register/default.aspx",0,2)
$ViewValue=StringRegExp(BinaryToString($rContext[0]),'<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="(.*?)" />',3)
If @error Then MsgBox(48,"Error","Error")
$Cookies=StringRegExpReplace($rContext[3],"(.+); path=/.*","$1")
$ViewValue=$ViewValue[0]
$context="__EVENTTARGET=subSendMsm&__EVENTARGUMENT=&__VIEWSTATE="&AnsiURLEncode($ViewValue)&"&txtUserNumber="&$TelNumber&"&hdSource=&hdInviteUid=0&hdInviteSeqno=&hdInviteType=&hdInviteGroup="
$rContext=_WinHTTP_GetRespond($MyOpen,"http://mail.10086.cn/Register/default.aspx",1,2,10000,1,$context,$Cookies,"Content-Type: application/x-www-form-urlencoded")
Switch $rContext[1]
Case 302
MsgBox(64,"Congratulation!","用户: "&$TelNumber&" 未被注册~")
Case Else
MsgBox(48,"I'm Sorry~","用户: "&$TelNumber&" 已经被注册!")
EndSwitch
_WinHttpCloseHandle($MyOpen)
Func AnsiURLEncode($str, $falg = 0)
;转换字符串为ANSI(GB2312)URL编码By afan
;可选参数$falg = 0,不转换字母及数字(默认);$falg = 1,全部转换(字符头http://除外)
Local $str_s = StringRegExpReplace($str, '^(http://).+', '$1')
If @extended = 0 Then $str_s = ''
If @extended > 0 Then $str = StringRegExpReplace($str, '^http://', '')
Local $astr, $i, $s2d, $sS = StringSplit($str, '')
For $i = 1 To UBound($sS) - 1
If StringRegExp($sS[$i], '[^\x00-\xff]') Then
$s2d = StringToBinary($sS[$i] & ' ')
$astr &= '%' & StringMid($s2d, 3, 2) & '%' & StringMid($s2d, 5, 2)
ElseIf StringRegExp($sS[$i], '[^\w]') Then
$s2d = StringToBinary($sS[$i])
$astr &= '%' & StringMid($s2d, 3, 2)
Else
If $falg = 0 Then $astr &= $sS[$i]
If $falg <> 0 Then
$s2d = StringToBinary($sS[$i])
$astr &= '%' & StringMid($s2d, 3, 2)
EndIf
EndIf
Next
$astr = StringReplace($astr, '%20', '+') ;转换空格的编码为'+'号,也可不要此行
Return $str_s & $astr
EndFunc ;==>AnsiURLEncode