Ver Fonte

Merge pull request #477 from jhao104/release-2.1.0

[update] :heavy_check_mark: readthedocs
J_hao104 há 6 anos atrás
pai
commit
dfade31602

+ 3 - 3
README.md

@@ -19,11 +19,11 @@ ProxyPool 爬虫代理IP池
 
 ### ProxyPool
 
-* 文档: [document](https://proxy-pool.readthedocs.io/zh/2.1.0/)
+* 文档: [document](https://proxy-pool.readthedocs.io/zh/2.1.0/) [![Documentation Status](https://readthedocs.org/projects/proxy-pool/badge/?version=latest)](https://proxy-pool.readthedocs.io/zh/latest/?badge=latest)
 
 * 支持版本: ![](https://img.shields.io/badge/Python-2.x-green.svg) ![](https://img.shields.io/badge/Python-3.x-blue.svg)
 
-* 测试地址: http://118.24.52.95 (单机勿压, 感谢。 恶意访问关[小黑屋](https://github.com/jhao104/proxy_pool/blob/bff423dffe6e2881ee45d5b66d8a6ad682c8e4ab/doc/block_ips.md)哦)
+* 测试地址: http://118.24.52.95 (单机勿压)
 
 * 有时间的朋友帮忙点下末尾的[推广](https://tracking.gitads.io/?repo=proxy_pool)哦 :stuck_out_tongue_winking_eye:
 
@@ -49,7 +49,7 @@ https://github.com/jhao104/proxy_pool/releases 下载对应zip文件
 pip install -r requirements.txt
 ```
 
-#### 修改配置:
+##### 更新配置:
 
 
 ```python

+ 4 - 0
docs/dev/extend_fetcher.rst

@@ -0,0 +1,4 @@
+.. extend_fetcher
+
+扩展代理源
+-----------

+ 1 - 2
docs/index.rst

@@ -110,5 +110,4 @@ Contents
 .. toctree::
    :maxdepth: 2
 
-   user/intro.rst
-
+   user/index

+ 71 - 0
docs/user/how_to_config.rst

@@ -0,0 +1,71 @@
+.. how_to_config
+
+配置参考
+---------
+
+配置文件 ``setting.py`` 位于项目的主目录下, 配置主要分为四类: **服务配置** 、 **数据库配置** 、 **采集配置** 、 **校验配置**.
+
+服务配置
+>>>>>>>>>
+
+* ``HOST``
+
+    API服务监听的IP, 本机访问设置为 ``127.0.0.1``, 开启远程访问设置为: ``0.0.0.0``.
+
+* ``PORT``
+
+    API服务监听的端口.
+
+数据库配置
+>>>>>>>>>>>
+
+* ``DB_CONN``
+
+    用户存放代理IP的数据库URI, 配置格式为: ``db_type://[[user]:[pwd]]@ip:port/[db]``.
+
+    目前支持的db_type有: ``ssdb`` 、 ``redis``.
+
+    配置示例:
+
+.. code-block:: python
+
+    # SSDB IP: 127.0.0.1  Port: 8888
+    DB_CONN = 'ssdb://@127.0.0.1:8888'
+    # SSDB IP: 127.0.0.1  Port: 8899  Password:  123456
+    DB_CONN = 'ssdb://:123456@127.0.0.1:8888'
+
+    # Redis IP: 127.0.0.1  Port: 6379
+    DB_CONN = 'redis://@127.0.0.1:6379'
+    # Redis IP: 127.0.0.1  Port: 6379  Password:  123456
+    DB_CONN = 'redis://:123456@127.0.0.1:6379'
+    # Redis IP: 127.0.0.1  Port: 6379  Password:  123456  DB: 15
+    DB_CONN = 'redis://:123456@127.0.0.1:6379/15'
+
+
+* ``TABLE_NAME``
+
+    存放代理的数据载体名称, ssdb和redis的存放结构为hash.
+
+采集配置
+>>>>>>>>>
+
+* ``PROXY_FETCHER``
+
+    启用的代理采集方法名, 代理采集方法位于 ``fetcher/proxyFetcher.py`` 类中.
+
+    由于各个代理源的稳定性不容易掌握, 当某个代理采集方法失效时, 可以该配置中注释掉其名称.
+
+    如果有增加某些代理采集方法, 也请在该配置中添加其方法名, 具体请参考 :doc:`/dev/extend_fetcher`.
+
+    调度程序每次执行采集任务时都会再次加载该配置, 保证每次运行的采集方法都是有效的.
+
+校验配置
+>>>>>>>>>
+
+* ``VERIFY_RUL``
+
+    用于检验代理是否可用的地址, 默认为 ``http://www.baidu.com``, 可根据使用场景修改为其他地址.
+
+* ``VERIFY_TIMEOUT``
+
+    检验代理的超时时间, 默认为 ``10`` , 单位秒. 使用代理访问 ``VERIFY_RUL`` 耗时超过 ``VERIFY_TIMEOUT`` 时, 视为代理不可用.

+ 73 - 0
docs/user/how_to_run.rst

@@ -0,0 +1,73 @@
+.. how_to_run
+
+
+如何运行
+---------
+
+下载代码
+>>>>>>>>>
+
+本项目需要下载代码到本地运行, 通过 ``git`` 下载:
+
+.. code-block:: console
+
+    $ git clone git@github.com:jhao104/proxy_pool.git
+
+或者下载特定的 ``release`` 版本:
+
+.. code-block:: console
+
+    https://github.com/jhao104/proxy_pool/releases
+
+安装依赖
+>>>>>>>>>
+
+到项目目录下使用 ``pip`` 安装依赖库:
+
+.. code-block:: console
+
+    $ pip install -r requirements.txt
+
+
+更新配置
+>>>>>>>>>
+
+配置文件 ``setting.py`` 位于项目的主目录下:
+
+.. code-block:: python
+
+    # 配置API服务
+
+    HOST = "0.0.0.0"               # IP
+    PORT = 5000                    # 监听端口
+
+    # 配置数据库
+
+    DB_CONN = 'redis://@127.0.0.1:8888/0'
+
+    # 配置 ProxyFetcher
+
+    PROXY_FETCHER = [
+        "freeProxy01",      # 这里是启用的代理抓取方法,所有fetch方法位于fetcher/proxyFetcher.py
+        "freeProxy02",
+        # ....
+    ]
+
+更多配置请参考 :doc:`/user/how_to_config`
+
+启动项目
+>>>>>>>>>
+
+如果已配置好运行环境, 具备运行条件, 可以通过 ``proxyPool.py`` 启动.  ``proxyPool.py`` 是项目的CLI入口.
+完整程序包含两部份: ``schedule`` 调度程序和 ``server`` API服务, 调度程序负责采集和验证代理, API服务提供代理服务HTTP接口.
+
+通过命令行程序分别启动调度程序和API服务:
+
+.. code-block:: console
+
+    # 启动调度程序
+    $ python proxyPool.py schedule
+
+    # 启动webApi服务
+    $ python proxyPool.py server
+

+ 7 - 0
docs/user/how_to_use.rst

@@ -0,0 +1,7 @@
+.. how_to_use
+
+如何使用
+----------
+
+爬虫代码要对接代理池目前有两种方式: 一是通过调用API接口使用, 二是直接读取数据库.
+

+ 12 - 0
docs/user/index.rst

@@ -0,0 +1,12 @@
+=========
+用户指南
+=========
+
+.. module:: user
+
+.. toctree::
+   :maxdepth: 2
+
+   how_to_run
+   how_to_use
+   how_to_config

+ 0 - 8
docs/user/intro.rst

@@ -1,8 +0,0 @@
-.. intro
-
-用户手册
-========
-
-安装
-------
-