免费采集( 采集免费的代理资源为爬虫提供有效的IP代理版本更新 )
优采云 发布时间: 2022-02-21 03:18免费采集(
采集免费的代理资源为爬虫提供有效的IP代理版本更新
)
Golang实现的IP代理池
采集免费代理资源为爬虫提供有效的IP代理
版本更新 2019 年 2 月 2 日 v2.2 感谢@sndnvaps 2018 年 8 月 17 日 v2.1 感谢 @harrybi 2018 年 7 月 17 日 v2.0 感谢 @sndnvaps 3 月 30 日, 2017 v1.01、代理池设计
代理池由四部分组成:
代理获取接口,目前有9个免费代理源,每次调用都会抓取这网站最新的100个代理,放入Channel中,你可以自己做;
临时存储来自采集的agent,通过访问stable 网站验证agent的有效性,如果有效则存储到数据库中;
使用定时任务检测数据库中代理IP的可用性,并删除不可用的代理。同时也会主动通过Getter获取最新代理;
代理池的访问接口提供了get接口输出JSON,方便爬虫直接使用。
2、代码实现
API接口相关代码,提供get接口,输出JSON;
代理获取接口,目前抓取网站的这9个免费代理,当然也支持自己扩展的代理接口;
快速代理代理66IP181有代理西刺代理国板家新闻代理无忧代理Proxylist+
存储一些公共模块、方法或函数;
配置文件:conf/app.ini、数据库、日志配置和代理获取接口配置;
<p>; 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