39

GitHub - chenerzhu/proxy-pool: java代理IP池 Proxy Pool,提供可用率达到95%以上的...

 5 years ago
source link: https://github.com/chenerzhu/proxy-pool
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

proxy-pool 代理IP

背景

前段时间,写java爬虫来爬网易云音乐的评论。不料,爬了一段时间后ip被封禁了。由此,想到了使用ip代理,但是找了很多的ip代理网站,很少有可以用的代理ip。于是,抱着边学习的心态,自己开发了一个代理ip池。

相关技术及环境

技术: SpringBoot,SpringMVC, Hibernate, MySQL, Redis , Maven, Lombok, BootStrap-table,多线程并发
环境: JDK1.8 , IDEA

实现功能

通过ip代理池,提供高可用的代理ip,可用率达到95%以上。

{
    "code":200,
    "data":[
        {
            "available":true,
            "ip":"1.10.186.214",
            "lastValidateTime":"2018-09-25 20:31:52",
            "location":"THThailand",
            "port":57677,
            "requestTime":0,
            "responseTime":0,
            "type":"https",
            "useTime":3671
        }
    ],
    "message":"success"
}

home.PNG

设计思路

模块划分

  • 爬虫模块:爬取代理ip网站的代理IP信息,先通过队列再保存进数据库。
  • 数据库同步模块:设置一定时间间隔同步数据库IP到redis缓存中。
  • 缓存redis同步模块:设置一定时间间隔同步redis缓存到另一块redis缓存中。
  • 缓存redis代理ip校验模块:设置一定时间间隔redis缓存代理ip池校验。
  • 前端显示及接口控制模块:显示可用ip页面,及提供ip获取api接口。

架构图

crawler.PNG

IP来源

代理ip均来自爬虫爬取,有些国内爬取的ip大多都不能用,代理池的ip可用ip大多是国外的ip。爬取的网站有:http://www.xicidaili.com/nnhttp://www.data5u.com/free/index.shtmlhttps://free-proxy-list.nethttps://www.my-proxy.com/free-proxy-list.htmlhttp://spys.one/en/free-proxy-list/https://www.proxynova.com/proxy-server-list/https://www.proxy4free.com/list/webproxy1.htmlhttp://www.gatherproxy.com/

如何使用

前提: 已经安装JDK1.8环境,MySQL数据库,Redis。
先使用maven编译成jar,proxy-pool-1.0.jar。
使用SpringBoot启动方式,启动即可。

java -jar proxy-pool-1.0.jar

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK