Forráskód Böngészése

Merge remote-tracking branch 'remotes/origin/master' into zspishere-master

jhao 6 éve
szülő
commit
78731bccd2
7 módosított fájl, 140 hozzáadás és 9 törlés
  1. 1 1
      README.md
  2. 72 0
      docs/changelog.rst
  3. 3 2
      docs/index.rst
  4. 56 0
      docs/user/how_to_use.rst
  5. 1 1
      docs/user/index.rst
  6. 6 4
      handler/logHandler.py
  7. 1 1
      proxyPool.py

+ 1 - 1
README.md

@@ -223,7 +223,7 @@ PROXY_FETCHER = [
 
 ### Release Notes
 
-   [release notes](https://github.com/jhao104/proxy_pool/blob/master/doc/release_notes.md)
+   [changelog](https://github.com/jhao104/proxy_pool/blob/master/docs/changelog.rst)
 
 ### AD
 

+ 72 - 0
docs/changelog.rst

@@ -0,0 +1,72 @@
+.. _changelog:
+
+ChangeLog
+==========
+
+2.1.0 (2020.07)
+------------------
+
+1. 新增免费代理源 **西拉代理**  (2020-03-30)
+2. Fix Bug `#356`_ `#401`_
+3. 优化Docker镜像体积; (2020-06-19)
+4. 优化配置方式;
+5. 优化代码结构;
+6. 不再储存raw_proxy, 抓取后直接验证入库;
+
+.. _#401: https://github.com/jhao104/proxy_pool/issues/401
+.. _#356: https://github.com/jhao104/proxy_pool/issues/356
+
+2.0.1 (2019.10)
+-----------------
+
+1. 新增免费代理源 **89免费代理**;
+#. 新增免费代理源 **齐云代理**
+
+2.0.0 (2019.08)
+------------------
+
+1. WebApi集成Gunicorn方式启动, Windows平台暂不支持;
+#. 优化Proxy调度程序;
+#. 扩展Proxy属性;
+#. 新增cli工具, 更加方便启动proxyPool
+
+1.14  (2019.07)
+-----------------
+
+1. 修复 Queue阻塞导致的 ``ProxyValidSchedule`` 假死bug;
+#. 修改代理源 **云代理** 抓取;
+#. 修改代理源 **码农代理** 抓取;
+#. 修改代理源 **代理66** 抓取, 引入 ``PyExecJS`` 模块破解加速乐动态Cookies加密;
+
+1.13  (2019.02)
+-----------------
+
+1. 使用.py文件替换.ini作为配置文件;
+
+#. 优化代理采集部分;
+
+1.12  (2018.04)
+-----------------
+
+1. 优化代理格式检查;
+
+#. 增加代理源;
+
+#. fix bug `#122`_  `#126`_
+
+.. _#122: https://github.com/jhao104/proxy_pool/issues/122
+.. _#126: https://github.com/jhao104/proxy_pool/issues/126
+
+1.11  (2017.08)
+-----------------
+
+1. 使用多线程验证useful_pool;
+
+1.10  (2016.11)
+-----------------
+
+1. 第一版;
+
+#. 支持PY2/PY3;
+
+#. 代理池基本功能;

+ 3 - 2
docs/index.rst

@@ -100,8 +100,8 @@ Api               Method      Description            Arg
                return html
            except Exception:
                retry_count -= 1
-       # 删除代理池中代理
-       delete_proxy(proxy)
+               # 删除代理池中代理
+               delete_proxy(proxy)
        return None
 
 Contents
@@ -111,3 +111,4 @@ Contents
    :maxdepth: 2
 
    user/index
+   changelog

+ 56 - 0
docs/user/how_to_use.rst

@@ -5,3 +5,59 @@
 
 爬虫代码要对接代理池目前有两种方式: 一是通过调用API接口使用, 二是直接读取数据库.
 
+调用API
+>>>>>>>>>
+
+启动ProxyPool的 ``server`` 后会提供如下几个http接口:
+
+============     ========    ================       ==============
+Api               Method      Description            Arg
+============     ========    ================       ==============
+/                GET         API介绍                 无
+/get             GET         随机返回一个代理         无
+/get_all         GET         返回所有代理             无
+/get_status      GET         返回代理数量             无
+/delete          GET         删除指定代理             proxy=host:ip
+============     ========    ================       ==============
+
+在代码中可以通过封装上面的API接口来使用代理, 例子:
+
+.. code-block:: python
+
+   import requests
+
+   def get_proxy():
+       return requests.get("http://127.0.0.1:5010/get/").json()
+
+   def delete_proxy(proxy):
+       requests.get("http://127.0.0.1:5010/delete/?proxy={}".format(proxy))
+
+   # your spider code
+
+   def getHtml():
+       # ....
+       retry_count = 5
+       proxy = get_proxy().get("proxy")
+       while retry_count > 0:
+           try:
+               # 使用代理访问
+               html = requests.get('http://www.example.com', proxies={"http": "http://{}".format(proxy)})
+               return html
+           except Exception:
+               retry_count -= 1
+               # 删除代理池中代理
+               delete_proxy(proxy)
+       return None
+
+本例中我们在本地 ``127.0.0.1`` 启动端口为 ``5010`` 的 ``server``, 使用 ``/get`` 接口获取代理, ``/delete`` 删除代理.
+
+读数据库
+>>>>>>>>>
+
+目前支持配置两种数据库: ``REDIS`` 、 ``SSDB``.
+
+* **REDIS** 储存结构为 ``hash``, hash name为配置项中的 **TABLE_NAME**
+
+* **SSDB** 储存结构为 ``hash``, hash name为配置项中的 **TABLE_NAME**
+
+可以在代码中自行读取.

+ 1 - 1
docs/user/index.rst

@@ -9,4 +9,4 @@
 
    how_to_run
    how_to_use
-   how_to_config
+   how_to_config

+ 6 - 4
handler/logHandler.py

@@ -7,15 +7,16 @@
    date:          2017/3/6
 -------------------------------------------------
    Change Activity:
-                   2017/3/6: log handler
-                   2017/9/21: 屏幕输出/文件输出 可选(默认屏幕和文件均输出)
+                   2017/03/06: log handler
+                   2017/09/21: 屏幕输出/文件输出 可选(默认屏幕和文件均输出)
+                   2020/07/13: Windows下TimedRotatingFileHandler线程不安全, 不再使用
 -------------------------------------------------
 """
 __author__ = 'JHao'
 
 import os
-
 import logging
+import platform
 
 from logging.handlers import TimedRotatingFileHandler
 
@@ -49,7 +50,8 @@ class LogHandler(logging.Logger):
         if stream:
             self.__setStreamHandler__()
         if file:
-            self.__setFileHandler__()
+            if platform.system() != "Windows":
+                self.__setFileHandler__()
 
     def __setFileHandler__(self, level=None):
         """

+ 1 - 1
proxyPool.py

@@ -35,7 +35,7 @@ def schedule():
 
 
 @cli.command(name="server")
-def schedule():
+def server():
     """ 启动api服务 """
     click.echo(BANNER)
     runFlask()