;AutoIT 获取公网IP
;在网上找到的很实用
;因为是英文帮助,所以不太明白StringRegExp的用法
$begin = TimerInit()
$ip = _GetIP()
msgbox(0,TimerDiff($begin),$ip)
Func _GetIP()
$ipurl = 'http://ip.91cool.net/ip.php?type=ip' & @cr & _
'http://www.123cha.com/ip/' & @cr & _
'http://www.ip138.com/' & @cr & _
'http://www.whatismyip.com'
$url = StringSplit($ipurl, @cr)
For $i = 1 to $url[0]
If InetGet($url[$i], @TempDir & "\~ip.tmp") Then
$ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
FileDelete(@TempDir & "\~ip.tmp")
$ip = StringRegExp($ip, '((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]
EndIf
Next
SetError(1)
Return -1
EndFunc
posted on 2007-09-28 14:49
疾风随影 阅读(828)
评论(0) 编辑 收藏 引用 所属分类:
Script & Batch column