增加客户端信息
This commit is contained in:
Binary file not shown.
@@ -33,18 +33,25 @@ func main() {
|
|||||||
log.Fatalf("无效的 IP 地址: %s", ip)
|
log.Fatalf("无效的 IP 地址: %s", ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
//https://qifu.baidu.com/ip/geo/v1/district?ip=146.190.59.217
|
|
||||||
|
|
||||||
// 目标 URL
|
// 目标 URL
|
||||||
url := "https://qifu.baidu.com/ip/geo/v1/district?ip=" + ip
|
url := "https://qifu.baidu.com/ip/geo/v1/district?ip=" + ip
|
||||||
|
|
||||||
|
// 创建 HTTP 请求
|
||||||
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("创建请求时出错: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置 User-Agent 为 Google Chrome
|
||||||
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36")
|
||||||
|
|
||||||
// 创建 HTTP 客户端并设置超时时间
|
// 创建 HTTP 客户端并设置超时时间
|
||||||
client := &http.Client{Timeout: 10 * time.Second}
|
client := &http.Client{Timeout: 10 * time.Second}
|
||||||
|
|
||||||
// 发送 GET 请求
|
// 发送请求
|
||||||
resp, err := client.Get(url)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("发送 GET 请求时出错: %v", err)
|
log.Fatalf("发送请求时出错: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
@@ -66,5 +73,4 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s%s\n", ipInfo.Data.Continent, ipInfo.Data.Country)
|
fmt.Printf("%s%s\n", ipInfo.Data.Continent, ipInfo.Data.Country)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -58,7 +58,7 @@ info:
|
|||||||
@echo "LIBIPSET: $(LIBIPSET)"
|
@echo "LIBIPSET: $(LIBIPSET)"
|
||||||
|
|
||||||
ipquery: # Go 构建目标
|
ipquery: # Go 构建目标
|
||||||
cd IP_region_query && CGO_ENABLED=0 go build -ldflags '-w -s'
|
cd IP_region_query && CGO_ENABLED=0 go build -ldflags '-w -s' && upx -9 ipquery
|
||||||
|
|
||||||
$(BIN): cap.o common.o ip2region/ip2region.o ip2region/xdb_searcher.o libipset.o
|
$(BIN): cap.o common.o ip2region/ip2region.o ip2region/xdb_searcher.o libipset.o
|
||||||
$(CC) $(CFLAGS) -o $(BIN) $^ $(LIBPCAP) $(LIBCAP) $(LIBIPSET) $(LIBS)
|
$(CC) $(CFLAGS) -o $(BIN) $^ $(LIBPCAP) $(LIBCAP) $(LIBIPSET) $(LIBS)
|
||||||
|
|||||||
Reference in New Issue
Block a user