/
re_xseo.go
58 lines (47 loc) · 902 Bytes
/
re_xseo.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package job
import (
"github.com/phpgao/proxy_pool/model"
"github.com/phpgao/proxy_pool/util"
"regexp"
"strings"
)
func init() {
spider := xseo{}
if spider.Enabled() {
register(spider)
}
}
func (s xseo) StartUrl() []string {
return []string{
"http://xseo.in/freeproxy",
}
}
func (s xseo) GetReferer() string {
return "http://xseo.in"
}
type xseo struct {
Spider
}
func (s xseo) Cron() string {
return "@every 5m"
}
func (s xseo) Name() string {
return "xseo"
}
func (s xseo) Run() {
getProxy(s)
}
func (s xseo) Parse(body string) (proxies []*model.HttpProxy, err error) {
reg := regexp.MustCompile(util.RegProxy)
rs := reg.FindAllString(body, -1)
for _, proxy := range rs {
if strings.Contains(proxy, ":") {
proxyInfo := strings.Split(proxy, ":")
proxies = append(proxies, &model.HttpProxy{
Ip: proxyInfo[0],
Port: proxyInfo[1],
})
}
}
return
}