Git Product home page Git Product logo

pyproxy-async's Introduction

PyProxy-Async

基于 Python 协程 + Redis 实现的简单的代理池维护,及代理 IP 抓取服务

流程图

流程图

Features

  • HTTP/HTTPS 检测
  • 协程实现
  • Web Api 接口支持

TODO

  • Docker Support
  • Custom check rule Support
  • TSDB Support (Prometheus has been supported)
  • More api Support

Usage

环境依赖 Python 3.6 +

  1. 克隆
git clone https://github.com/pjialin/pyproxy-async
cd pyproxy-async
  1. 安装依赖
pip install -r requirements.txt 
  1. 完善配置文件
cp config.toml.example config.toml
  1. 启动
python main.py

Docker 使用

  1. 拉取镜像
docker pull pjialin/pyproxy-async:latest
  1. 下载配置文件
curl -o config.toml https://raw.githubusercontent.com/pjialin/pyproxy-async/master/config.toml.example
  1. 启动
docker run -d -v $(PWD)/config.toml:/code/config.toml -v pyproxy-data:/code/data --name pyproxy pjialin/pyproxy-async:latest

Web Api

启动完成之后,访问 127.0.0.1:8080/get_ip (配置文件中的端口),即可获得一个随机的 IP, 如

# curl http://127.0.0.1:8080/get_ip  
{"ip":"213.6.45.18","port":"39252","http":"http://213.6.45.18:39252"}

# 支持过滤条件 https,rule 如
curl http://127.0.0.1:8080/get_ip?https=1&rule=google

从文件或 Url 中加载已存在的 IP 列表

文件

  1. 将文件命名为 *.ip.txt,如 new.ip.txt,并放在根目录下,文件格式为 host:port,如
127.0.0.1:80
127.0.0.1:8080
  1. 加载到 IP 池中
python load.py [file_name]  # 默认加载所有 *.ip.txt 文件

从 Url 中加载

python load.py url # 如 python load.py https://ser.com/ip  支持任意文本,程序通过正则进行匹配

添加抓取服务

增加新的 IP 抓取服务非常简单,只需要定义好要抓取的页面和对应的解析器,框架会自动加载并进行抓取。 在 src/sites 目录中提供了一个示例文件,site.py.example,供参考

集群支持

目前支持使用同一个 Redis 地址,实现集群 IP 检测以及抓取

License

Apache License 2.0

pyproxy-async's People

Contributors

pjialin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.