关于函数_getip的问题
有人发现这个函数最近总返回异常结果吗?Func _GetIP()
Local $aReturn, $bRead, $sRead
$bRead = InetRead("http://checkip.dyndns.org/")
$sRead = BinaryToString($bRead)
$aReturn = StringRegExp($sRead, '(?s)(?i)<body>Current IP Address: (.*?)</body>', 3)
If Not @error Then
Return $aReturn
EndIf
$bRead = InetRead("http://www.whatismyip.com/automation/n09230945.asp") ; http://forum.whatismyip.com/f14/our-automation-rules-t241/
$sRead = BinaryToString($bRead)
If @error Then
Return SetError(1, 0, -1)
EndIf
Return $sRead
EndFunc ;==>_GetIP
本帖最后由 cxlater 于 2011-12-18 00:00 编辑
感谢群里的 cross door提供
Func _GetIP()
$bRead = InetRead("http://www.newhua.com/ajax_ip.php")
$return = BinaryToString($bRead)
$IP = StringRegExp($return, '((2\d|25|?\d\d?)\.){3}(2\d|25|?\d\d?)', 2)
If Not @error Then
Return ($IP)
Else
Return SetError(1, 0, 1)
EndIf
EndFunc
Func _GetIP()
$Url = 'http://www.ip138.com/ip2city.asp'
$rContext = _WinHTTP_GetRespond($MyOpen, $Url, 2 + 4 + 512 + 256)
If @error Then
$Url = 'http://checkip.dyndns.org'
$rContext = _WinHTTP_GetRespond($MyOpen, $Url, 2 + 4 + 512 + 256)
If @error Then Return SetError(@ScriptLineNumber, 1, 1)
$sRegExp = StringRegExp(BinaryToString($rContext), '(?i)Address: (.*?)</body>', 3)
If Not @error Then Return $sRegExp
Else
$sRegExp = StringRegExp(BinaryToString($rContext), '(?i)\[(.*?)\]', 3)
If Not @error Then Return $sRegExp
EndIf
Return SetError(-9, 1, 1)
EndFunc ;==>_GetIP保险一点。。。用默认的好像有时候很慢... 感谢群里的 cross door提供
页:
[1]