package ip import ( "net/http" "HFish/error" "io/ioutil" "github.com/axgle/mahonia" "regexp" "strings" "net" "fmt" "HFish/utils/try" "HFish/utils/log" ) // 爬虫 ip138 获取 ip 地理信息 func Get(ip string) string { result := "" try.Try(func() { resp, err := http.Get("http://ip138.com/ips138.asp?ip=" + ip) error.Check(err, "请求IP138异常") defer resp.Body.Close() input, err := ioutil.ReadAll(resp.Body) error.Check(err, "读取IP138内容异常") out := mahonia.NewDecoder("gbk").ConvertString(string(input)) reg := regexp.MustCompile(`