找回密码
 加入
搜索
查看: 2333|回复: 3

[网络通信] 关于函数_getip的问题

[复制链接]
发表于 2011-12-17 21:41:23 | 显示全部楼层 |阅读模式
有人发现这个函数最近总返回异常结果吗?


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[0]
    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
 楼主| 发表于 2011-12-17 23:23:16 | 显示全部楼层
本帖最后由 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[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)', 2)
        If Not @error Then
                Return ($IP[0])
        Else
                Return SetError(1, 0, 1)
        EndIf
EndFunc
发表于 2011-12-18 01:35:59 | 显示全部楼层
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[0]), '(?i)Address: (.*?)</body>', 3)
                If Not @error Then Return $sRegExp[0]
        Else
                $sRegExp = StringRegExp(BinaryToString($rContext[0]), '(?i)\[(.*?)\]', 3)
                If Not @error Then Return $sRegExp[0]
        EndIf
        Return SetError(-9, 1, 1)
EndFunc   ;==>_GetIP
保险一点。。。用默认的好像有时候很慢...
发表于 2011-12-19 16:39:11 | 显示全部楼层
感谢群里的 cross door提供
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-1 03:23 , Processed in 0.093847 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表