All Projects → henson → Proxypool

henson / Proxypool

Licence: apache-2.0
Golang实现的IP代理池

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Proxypool

HttpProxy
JAVA实现的IP代理池,支持HTTP与HTTPS两种方式
Stars: ✭ 37 (-96.74%)
Mutual labels:  ip, proxypool
Ok ip proxy pool
🍿爬虫代理IP池(proxy pool) python🍟一个还ok的IP代理池
Stars: ✭ 196 (-82.72%)
Mutual labels:  ip, proxypool
Spoon
🥄 A package for building specific Proxy Pool for different Sites.
Stars: ✭ 173 (-84.74%)
Mutual labels:  ip, proxypool
IpProxyPool
Golang 实现的 IP 代理池, 涉及到的技术点: go gorm proxy proxypool ip crawler 爬虫 mysql viper cobra
Stars: ✭ 36 (-96.83%)
Mutual labels:  ip, proxypool
Snoop
Snoop — инструмент разведки на основе открытых данных (OSINT world)
Stars: ✭ 886 (-21.87%)
Mutual labels:  ip
Proxyiplib
全球免费代理IP库,高可用IP,精心筛选优质IP,2s必达
Stars: ✭ 521 (-54.06%)
Mutual labels:  ip
Cuteit
IP obfuscator made to make a malicious ip a bit cuter
Stars: ✭ 475 (-58.11%)
Mutual labels:  ip
Information collection handbook
Handbook of information collection for penetration testing and src
Stars: ✭ 447 (-60.58%)
Mutual labels:  ip
X Proxies
Usable ip proxies, crawling from some proxy websites.
Stars: ✭ 53 (-95.33%)
Mutual labels:  ip
Lua Libcidr Ffi
LuaJIT FFI bindings to libcidr. Provides CIDR calculations for IPv4 and IPv6.
Stars: ✭ 43 (-96.21%)
Mutual labels:  ip
Api
姬长信API For Docker 一个基于多种编程语言开源免费不限制提供生活常用,出行服务,开发工具,金融服务,通讯服务和公益大数据的平台.
Stars: ✭ 743 (-34.48%)
Mutual labels:  ip
Nali
An offline tool for querying IP geographic information and CDN provider.一个查询IP地理信息和CDN服务提供商的离线终端工具.
Stars: ✭ 535 (-52.82%)
Mutual labels:  ip
Cdn dig
用于在linux 终端快速查询全国 CDN 调度到哪些区域节点的工具
Stars: ✭ 36 (-96.83%)
Mutual labels:  ip
Request Ip
A Node.js module for retrieving a request's IP address on the server.
Stars: ✭ 501 (-55.82%)
Mutual labels:  ip
Ipsubnet
Network calculator for subnet mask and other classless (CIDR) network information. ( GO )
Stars: ✭ 44 (-96.12%)
Mutual labels:  ip
Cnp3
Computer Networking : Principles, Protocols and Practice (first and second edition, third edition is being written on https://github.com/cnp3/ebook)
Stars: ✭ 471 (-58.47%)
Mutual labels:  ip
Hostile
Simple, programmatic `/etc/hosts` manipulation (in node.js)
Stars: ✭ 654 (-42.33%)
Mutual labels:  ip
Koa Ip
Ip filter middleware for koa, support whitelist and blacklist.
Stars: ✭ 37 (-96.74%)
Mutual labels:  ip
Cidranger
Fast IP to CIDR lookup in Golang
Stars: ✭ 586 (-48.32%)
Mutual labels:  ip
Qqwry.dat
自动更新的纯真ip库,每天自动更新
Stars: ✭ 559 (-50.71%)
Mutual labels:  ip

Golang实现的IP代理池

采集免费的代理资源为爬虫提供有效的IP代理

Travis Status for henson/proxypool Go Report Card

Stargazers over time

Stargazers over time

版本更新

  • 2019年12月18日 v2.4 感谢 @sndnvaps
    • 添加代理网站 ip3306, plp-ssl 两个
    • 更新 数据库结构,添加创建时间和更新时间
    • 更新 ip.go当中的Update(), x.Id()方法将会被x.ID()代替,所以直接更换为x.ID()
    • 更新 在插入数据时先检查库中是否存在,如果存在就更新,不存在则插入到数据库
    • 更新 https proxy api的相关参数
  • 2019年3月28日 v2.3 感谢 @sndnvaps
    • 修复数据库中不存在https代理源的时候查询出错的问题。解决问题#31
  • 2019年2月2日 v2.2 感谢 @sndnvaps
    • 添加MAC Darwin平台的支持
    • 添加完全的 sqlite3 支持
    • 添加新代理平台【feiyi,89ip】
    • fix一个bug【当数据库中无数据时,不能写入数据】
  • 2018年8月17日 v2.1 感谢 @harrybi
    • 对代理可用性的验证,增加speed字段,验证代理的速度(毫秒)
    • 调用API获取代理IP时自动过滤掉慢的代理(>=1s)
  • 2018年7月17日 v2.0 感谢 @sndnvaps
    • 使用 xorm 来处理数据库,支持 mysql、mssql、postgres 和 sqlite3
    • 更新相应爬虫程序
    • 加入日志
  • 2017年3月30日 v1.0
    • 采用 mongo 作为数据持久化
    • 结构简洁,适合二次开发

1、代理池设计

  代理池由四部分组成:

  • Getter:

  代理获取接口,目前有9个免费代理源,每调用一次就会抓取这些网站最新的100个代理放入Channel,可自行添加额外的代理获取接口

  • Channel:

  临时存放采集来的代理,通过访问稳定的网站去验证代理的有效性,有效则存入数据库;

  • Schedule:

  用定时的计划任务去检测数据库中代理IP的可用性,删除不可用的代理。同时也会主动通过Getter去获取最新代理;

  • Api:

  代理池的访问接口,提供get接口输出JSON,方便爬虫直接使用。

2、代码实现

  • Api:

  api接口相关代码,提供get接口,输出JSON;

  • Getter:

  代理获取接口,目前抓取这九个网站的免费代理,当然也支持自己扩展代理接口;

  1. 快代理
  2. 代理66
  3. IP181
  4. 有代理
  5. 西刺代理
  6. guobanjia
  7. 讯代理
  8. 无忧代理
  9. Proxylist+
  • Pkg:

  存放一些公共的模块、方法或函数;

  • 其他:

  配置文件:conf/app.ini,数据库、日志配置和代理获取接口配置;

; App name
APP_NAME = ProxyPool

[server]
HTTP_ADDR = 0.0.0.0
HTTP_PORT = 3000
;Session expires time
SESSION_EXPIRES =

[database]
; Either "mysql", "postgres" or "sqlite3", you can connect to TiDB with MySQL protocol
DB_TYPE = postgres
HOST = 127.0.0.1:5432
NAME = ProxyPool
USER = postgres
PASSWD =
; For "postgres" only, either "disable", "require" or "verify-full"
SSL_MODE = disable
; For "sqlite3" and "tidb", use absolute path when you start as service
PATH = data/ProxyPool.db

[log]
; Can be "console" and "file", default is "console"
; ; ; Use comma to separate multiple modes, e.g. "console, file"
MODE       = file
; Buffer length of channel, keep it as it is if you don't know what it is.
BUFFER_LEN = 100
; Either "Trace", "Info", "Warn", "Error", "Fatal", default is "Trace"
LEVEL      = Info
; Root path of log files, align will fill it automatically.
ROOT_PATH  =  

; For "console" mode only
[log.console]
; leave empty to inherit
LEVEL = Trace

; For "file" mode only
[log.file]
; leave empty to inherit
LEVEL          = Info
; This enables automated log rotate (switch of following options)
LOG_ROTATE     = true
; Segment log daily
DAILY_ROTATE   = true
; Max size shift of single file, default is 28 means 1 << 28, 256MB
MAX_SIZE_SHIFT = 28
; Max line number of single file
MAX_LINES      = 1000000
; Expired days of log file (delete after max days)
MAX_DAYS       = 7

[log.xorm]
; Enable file rotation
ROTATE = true
; Rotate every day
ROTATE_DAILY = true
; Rotate once file size excesses x MB
MAX_SIZE = 100
; Maximum days to keep logger files
MAX_DAYS = 3

[security]
INSTALL_LOCK = false

3、安装及使用

因为有些代理网站使用了加密页面、混淆代码等反爬技术,要正确采集到代理数据得用到 PhantomJS ,必须提前先装好。

另外,本项目用到的依赖库有:

clog "unknwon.dev/clog/v2"
github.com/go-ini/ini
github.com/go-xorm/xorm
github.com/go-xorm/core
github.com/go-sql-driver/mysql
github.com/lib/pq
github.com/Aiicy/htmlquery
github.com/PuerkitoBio/goquery
github.com/parnurzeal/gorequest
github.com/nladuo/go-phantomjs-fetcher

下载本项目:

go get -u github.com/henson/proxypool

然后配置好相应的app.ini并启动:

go build
./ProxyPool

随机输出可用的代理:

GET http://localhost:8080/v2/ip

HTTP

随机输出HTTPS代理:

GET http://localhost:8080/v2/https

HTTPS

4、添加自定义代理采集接口

其实很简单,只需要在getter包下新增一个采集函数(如例子的Data5u()),甚至可以不需要新建一个go文件(新建文件是为了方便归档采集函数,如例子5u.go)。

// 5u.go
// Data5u get ip from data5u.com
func Data5u() (result []*models.IP) {
    //处理逻辑
    ...
    log.Println("Data5u done.")
    return
}

然后在main.go的run函数中添加、删除或注释掉该采集函数的调用即可。

func run(ipChan chan<- *models.IP) {
    var wg sync.WaitGroup
    funs := []func() []*models.IP{
        getter.Data5u,
        getter.IP66,
        getter.KDL,
        getter.GBJ,
        getter.Xici,
        getter.XDL,
        //getter.IP181,
        //getter.YDL,
        getter.PLP,
    }
    ...
}

5、异常恢复

之前,偶尔会有朋友跟我反映程序无法编译,经过检查发现都是代理网站发生了变化(或修改了页面或关闭了网站),以致于采集程序原先设计的爬虫不能正常工作而导致了错误的发生。为此,我修改了代码,加入了容错机制,即便爬虫出错了也不会影响到主体程序的运行。出错的采集进程会被主线程忽略,其它正常的采集进程仍将继续工作。

6、诚挚的感谢

  • 首先感谢您的使用,如果觉得程序还不错也能帮助您解决实际问题,不妨添个赞以鼓励本人继续努力,谢谢!
  • 如果您对程序有任何建议和意见,也欢迎提交issue。
  • 当然,如果您愿意贡献代码和我一起改进本程序,那再好不过了。
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].