-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (34 loc) · 913 Bytes
/
main.go
File metadata and controls
38 lines (34 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"ipProxy/collection"
"ipProxy/proxy"
"net/http"
"strconv"
"time"
"strings"
)
func main() {
fmt.Println("GitHub:https://github.com/yqcs")
result := collection.StartCollectionProxyIp()
fmt.Println(">>>>采集完成,信息:")
fmt.Println(result)
fmt.Println(">>>>开始筛选IP")
for _, proxyInfo := range result {
fmt.Println(">>IP:" + proxyInfo.Ip)
url := strings.ToLower(proxyInfo.Agreement) + "://" + proxyInfo.Ip + ":" + strconv.Itoa(proxyInfo.Port)
timeout := time.Duration(3 * time.Second)
//设置3秒超时
client := http.Client{
Timeout: timeout,
}
_, err := client.Get(url)
//请求出错或者超时,就更换下一个
if err != nil {
fmt.Println("请求出错,或者是响应超时,目标:" + url)
continue
}
fmt.Println(">>>开始匿名请求")
proxy.StartRequestProxy("https://www.baidu.com/s?wd=ip", url)
}
}