获取公网IP

程序代码 程序代码

$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



你可能感兴趣的:(代码,职场,休闲)