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
53
53
1 . 编写代理池:例如在你的项目下创建个my_proxypool.py,实现下面的函数
54
54
55
55
```python
56
- from feapder.network.proxy_pool import ProxyPool
56
+ from feapder.network.proxy_pool import BaseProxyPool
57
57
58
- class MyProxyPool (ProxyPool ):
58
+ class MyProxyPool (BaseProxyPool ):
59
59
def get_proxy (self ):
60
60
"""
61
61
获取代理
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 7
7
@author: Boris
8
8
9
9
"""
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 13
13
from feapder .utils .log import log
14
14
15
15
16
- class ProxyPool :
16
+ class BaseProxyPool :
17
17
@abc .abstractmethod
18
18
def get_proxy (self ):
19
19
"""
Original file line number Diff line number Diff line change 12
12
import requests
13
13
14
14
import feapder .setting as setting
15
- from feapder .network .proxy_pool .base import ProxyPool
15
+ from feapder .network .proxy_pool .base import BaseProxyPool
16
16
from feapder .utils import metrics
17
17
from feapder .utils import tools
18
18
19
19
20
- class MemoryProxyPool ( ProxyPool ):
20
+ class ProxyPool ( BaseProxyPool ):
21
21
"""
22
22
通过API提取代理,存储在内存中,无代理时会自动提取
23
23
API返回的代理以 \r \n 分隔
Original file line number Diff line number Diff line change 21
21
from feapder .db .redisdb import RedisDB
22
22
from feapder .network import user_agent
23
23
from feapder .network .downloader .base import Downloader , RenderDownloader
24
- from feapder .network .proxy_pool import ProxyPool
24
+ from feapder .network .proxy_pool import BaseProxyPool
25
25
from feapder .network .response import Response
26
26
from feapder .utils .log import log
27
27
31
31
32
32
class Request :
33
33
user_agent_pool = user_agent
34
- proxies_pool : ProxyPool = None
34
+ proxies_pool : BaseProxyPool = None
35
35
36
36
cache_db = None # redis / pika
37
37
cached_redis_key = None # 缓存response的文件文件夹 response_cached:cached_redis_key:md5
Original file line number Diff line number Diff line change 133
133
PROXY_EXTRACT_API = None # 代理提取API ,返回的代理分割符为\r\n
134
134
PROXY_ENABLE = True
135
135
PROXY_MAX_FAILED_TIMES = 5 # 代理最大失败次数,超过则不使用,自动删除
136
- PROXY_POOL = "feapder.network.proxy_pool.MemoryProxyPool " # 代理池
136
+ PROXY_POOL = "feapder.network.proxy_pool.ProxyPool " # 代理池
137
137
138
138
# 随机headers
139
139
RANDOM_HEADERS = True
Original file line number Diff line number Diff line change 122
122
# PROXY_EXTRACT_API = None # 代理提取API ,返回的代理分割符为\r\n
123
123
# PROXY_ENABLE = True
124
124
# PROXY_MAX_FAILED_TIMES = 5 # 代理最大失败次数,超过则不使用,自动删除
125
- # PROXY_POOL = "feapder.network.proxy_pool.MemoryProxyPool " # 代理池
125
+ # PROXY_POOL = "feapder.network.proxy_pool.ProxyPool " # 代理池
126
126
#
127
127
# # 随机headers
128
128
# RANDOM_HEADERS = True
You can’t perform that action at this time.
0 commit comments