package ip import ( "net/http" "HFish/error" "io/ioutil" "github.com/djimenez/iconv-go" "regexp" "strings" "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 := make([]byte, len(input)) out = out[:] iconv.Convert(input, out, "gb2312", "utf-8") reg := regexp.MustCompile(`