#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("手机号归属地查询工具", 270, 270, 200, 120)
$Label1 = GUICtrlCreateLabel("手机号码", 20, 20, 80, 20)
$Input1 = GUICtrlCreateInput("在这里输入手机号", 90, 18, 170, 20,$ES_NUMBER)
$Button1 = GUICtrlCreateButton("确定查询", 10, 50, 250, 40, 0)
$Label2 = GUICtrlCreateLabel("归属地:", 10, 112, 84, 28)
$Label3 = GUICtrlCreateLabel("卡类型:", 10, 151, 74, 28)
$Label4 = GUICtrlCreateLabel("区 号:", 10, 192, 64, 28)
$Label5 = GUICtrlCreateLabel("邮 编:", 10, 227, 64, 28)
$Input2 = GUICtrlCreateInput("", 90, 105, 169, 32)
$Input3 = GUICtrlCreateInput("", 90, 147, 169, 32)
$Input4 = GUICtrlCreateInput("", 90, 190, 169, 32)
$Input5 = GUICtrlCreateInput("", 90, 227, 169, 32)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$telno = GUICtrlRead($Input1)
GUICtrlSetState($Button1,$gui_disable)
$telinfo = find138($telno)
GUICtrlSetState($Button1,$gui_enable)
If $telinfo[0] Then
GUICtrlSetData($Input2,$telinfo[2])
GUICtrlSetData($Input3,$telinfo[3])
GUICtrlSetData($Input4,$telinfo[4])
GUICtrlSetData($Input5,$telinfo[5])
Else
Exit
EndIf
EndSwitch
WEnd
Func find138($phn)
Local $telinfo[6] = [0, 0, 0, 0, 0,0], $dt = 0
$str = InetGet("http://www.ip138.com:8080/search.asp?action=mobile&mobile=" & $phn,@TempDir & "\data.tmp", 1, 1)
Do
Sleep(250)
$dt += 1
If $dt > 250 Then Return SetError(1,0,0)
Until InetGetInfo($str, 2)
InetClose($str)
$str = FileRead(@TempDir & "\data.tmp")
FileDelete(@TempDir & "\data.tmp")
$phoNo = StringRegExp($str, '您查询的手机号码段</TD>(?s)(.[^>]*)>(.[^<]*)(.*)' & _
'卡号归属地</TD>(?s)(.[^>]*)>(.[^<]*)(.*)' & _
'卡 类 型</TD>(?s)(.[^>]*)>(.[^<]*)(.*)' & _
'区 号</TD>(?s)(.[^>]*)>(.[^<]*)(.*)' & _
'邮 编</TD>(?s)(.[^>]*)>(.[^<]*)', 3)
If Not @error Then
$telinfo[1] = $phoNo[1]
$telinfo[2] = StringReplace($phoNo[4]," "," ")
$telinfo[3] = $phoNo[7]
$telinfo[4] = $phoNo[10]
$telinfo[5] = $phoNo[13]
$telinfo[0] = 5
Else
MsgBox(0, " 出错!!", "查询错误!!" & @CRLF & "错误代码: " & @error)
EndIf
Return $telinfo
EndFunc ;==>find138