elexy 发表于 2016-6-19 11:37:08

[已解决]公网IP网页获取后,中文乱码问题

本帖最后由 elexy 于 2016-6-19 12:53 编辑

#include <INet.au3>

Global $geturl = "http://1212.ip138.com/ic.asp"
$WinHttp = ObjCreate("WinHttp.WinHttprequest.5.1")
$WinHttp.Open("GET", $geturl, False)
$WinHttp.Send()
$WinHttp.WaitForResponse
Global $body = BinaryToString($WinHttp.Responsebody, 4)
$aIP = StringRegExp($body, '\[(\d[\d.]+)\]', 3)
MsgBox(64, $aIP, $body)
ClipPut($body)
$WinHttp = 0

Local $str = BinaryToString(_INetGetSource('http://1212.ip138.com/ic.asp', 0), 4)
MsgBox(64,0,$str)   

;两种方式中文都是乱码,导致抓不到地区,请高手们修改一下。

haijie1223 发表于 2016-6-19 12:05:07

在群里问的是你吧,和你说了是编码问题。ANSI#include <INet.au3>

Global $geturl = "http://1212.ip138.com/ic.asp"
$WinHttp = ObjCreate("WinHttp.WinHttprequest.5.1")
$WinHttp.Open("GET", $geturl, False)
$WinHttp.Send()
$WinHttp.WaitForResponse
Global $body = BinaryToString($WinHttp.Responsebody, 1)
$aIP = StringRegExp($body, '\[(\d[\d.]+)\]', 3)
MsgBox(64, $aIP, $body)
ClipPut($body)
$WinHttp = 0

Local $str = BinaryToString(_INetGetSource('http://1212.ip138.com/ic.asp', 0), 1)
MsgBox(64, 0, $str)

elexy 发表于 2016-6-19 12:54:21

谢谢楼上!!! 原来是4改成1。。。
页: [1]
查看完整版本: [已解决]公网IP网页获取后,中文乱码问题