# agent_pool **Repository Path**: zjxcode/agent_pool ## Basic Information - **Project Name**: agent_pool - **Description**: 一个简单的代理池(后台接口,redis) - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-01-05 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # agent_pool 一个简单的代理池(后台接口,redis) # 原理 抓取全网代理等免费代理,保存到redis数据库,然后用flask搭建接口 # 安装方法 安装python3,安装对应的依赖库(flask,requests,lxml),安装redis数据库 # 架构图 ![架构图](./1.png ) # 使用方法 按照架构图,启动四个部分即可运行。 1. 启动redis数据库 2. 启动server.py(用于后台接口) 3. 启动quanwangcrawler.py(用于采集免费代理,推荐使用全网) 4. 启动checkproxy.py(用于检测代理,推送到可用的代理池) ![使用方法](./2.png ) # 使用代理demo ``` import requests r = requests.get('http://127.0.0.1:5000/http', timeout=5) proxies = r.json() print(proxies) r = requests.get('http://www.w3school.com.cn', proxies=proxies, timeout=5) print(r.status_code) ``` # 结果 从redis上可以看到,采集到的代理用19个,其中17个是能用的。当然,你也可以编辑crawler部分,增加更多的代理。 ![结果](./3.png )