File tree Expand file tree Collapse file tree 8 files changed +12
-12
lines changed
templates/project_template Expand file tree Collapse file tree 8 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,9 @@ ip:port
53531 . 编写代理池:例如在你的项目下创建个my_proxypool.py,实现下面的函数
5454
5555 ```python
56- from feapder.network.proxy_pool import ProxyPool
56+ from feapder.network.proxy_pool import BaseProxyPool
5757
58- class MyProxyPool (ProxyPool ):
58+ class MyProxyPool (BaseProxyPool ):
5959 def get_proxy (self ):
6060 """
6161 获取代理
Original file line number Diff line number Diff line change 1- 1.8.7
1+ 1.8.8
Original file line number Diff line number Diff line change 77@author: Boris
88@email: boris_liu@foxmail.com
99"""
10- from .base import ProxyPool
11- from .memory_proxy_pool import MemoryProxyPool
10+ from .base import BaseProxyPool
11+ from .proxy_pool import ProxyPool
Original file line number Diff line number Diff line change 1313from feapder .utils .log import log
1414
1515
16- class ProxyPool :
16+ class BaseProxyPool :
1717 @abc .abstractmethod
1818 def get_proxy (self ):
1919 """
Original file line number Diff line number Diff line change 1212import requests
1313
1414import feapder .setting as setting
15- from feapder .network .proxy_pool .base import ProxyPool
15+ from feapder .network .proxy_pool .base import BaseProxyPool
1616from feapder .utils import metrics
1717from feapder .utils import tools
1818
1919
20- class MemoryProxyPool ( ProxyPool ):
20+ class ProxyPool ( BaseProxyPool ):
2121 """
2222 通过API提取代理,存储在内存中,无代理时会自动提取
2323 API返回的代理以 \r \n 分隔
Original file line number Diff line number Diff line change 2121from feapder .db .redisdb import RedisDB
2222from feapder .network import user_agent
2323from feapder .network .downloader .base import Downloader , RenderDownloader
24- from feapder .network .proxy_pool import ProxyPool
24+ from feapder .network .proxy_pool import BaseProxyPool
2525from feapder .network .response import Response
2626from feapder .utils .log import log
2727
3131
3232class Request :
3333 user_agent_pool = user_agent
34- proxies_pool : ProxyPool = None
34+ proxies_pool : BaseProxyPool = None
3535
3636 cache_db = None # redis / pika
3737 cached_redis_key = None # 缓存response的文件文件夹 response_cached:cached_redis_key:md5
Original file line number Diff line number Diff line change 133133PROXY_EXTRACT_API = None # 代理提取API ,返回的代理分割符为\r\n
134134PROXY_ENABLE = True
135135PROXY_MAX_FAILED_TIMES = 5 # 代理最大失败次数,超过则不使用,自动删除
136- PROXY_POOL = "feapder.network.proxy_pool.MemoryProxyPool " # 代理池
136+ PROXY_POOL = "feapder.network.proxy_pool.ProxyPool " # 代理池
137137
138138# 随机headers
139139RANDOM_HEADERS = True
Original file line number Diff line number Diff line change 122122# PROXY_EXTRACT_API = None # 代理提取API ,返回的代理分割符为\r\n
123123# PROXY_ENABLE = True
124124# PROXY_MAX_FAILED_TIMES = 5 # 代理最大失败次数,超过则不使用,自动删除
125- # PROXY_POOL = "feapder.network.proxy_pool.MemoryProxyPool " # 代理池
125+ # PROXY_POOL = "feapder.network.proxy_pool.ProxyPool " # 代理池
126126#
127127# # 随机headers
128128# RANDOM_HEADERS = True
You can’t perform that action at this time.
0 commit comments