cobweb-launcher 1.2.15__tar.gz → 1.2.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cobweb-launcher-1.2.15/cobweb_launcher.egg-info → cobweb-launcher-1.2.16}/PKG-INFO +1 -1
- cobweb-launcher-1.2.16/cobweb/__init__.py +2 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/db/__init__.py +1 -0
- cobweb-launcher-1.2.16/cobweb/db/api_db.py +71 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/launchers/__init__.py +1 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/launchers/launcher.py +2 -1
- cobweb-launcher-1.2.16/cobweb/launchers/launcher_api.py +226 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/launchers/launcher_pro.py +2 -2
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/setting.py +3 -1
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16/cobweb_launcher.egg-info}/PKG-INFO +1 -1
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb_launcher.egg-info/SOURCES.txt +2 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/setup.py +1 -1
- cobweb-launcher-1.2.15/cobweb/__init__.py +0 -2
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/LICENSE +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/README.md +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/base/__init__.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/base/common_queue.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/base/decorators.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/base/item.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/base/log.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/base/request.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/base/response.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/base/seed.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/constant.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/crawlers/__init__.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/crawlers/crawler.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/db/redis_db.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/exceptions/__init__.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/exceptions/oss_db_exception.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/launchers/launcher_air.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/pipelines/__init__.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/pipelines/pipeline.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/pipelines/pipeline_console.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/pipelines/pipeline_loghub.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/utils/__init__.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/utils/bloom.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/utils/oss.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb/utils/tools.py +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb_launcher.egg-info/dependency_links.txt +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb_launcher.egg-info/requires.txt +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb_launcher.egg-info/top_level.txt +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/setup.cfg +0 -0
- {cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/test/test.py +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ApiDB:
|
|
7
|
+
|
|
8
|
+
def __init__(self, host=None, **kwargs):
|
|
9
|
+
self.host = host or os.getenv("REDIS_API_HOST", "http://127.0.0.1:4396")
|
|
10
|
+
|
|
11
|
+
def _get_response(self, api, params: dict = None):
|
|
12
|
+
url = self.host + api
|
|
13
|
+
response = requests.get(url, params=params)
|
|
14
|
+
json_data = response.json()
|
|
15
|
+
return json_data["data"]
|
|
16
|
+
|
|
17
|
+
def _post_response(self, api, params: dict = None, data: dict = None):
|
|
18
|
+
url = self.host + api
|
|
19
|
+
headers = {"Content-Type": "application/json"}
|
|
20
|
+
response = requests.post(url, headers=headers, params=params, data=json.dumps(data))
|
|
21
|
+
json_data = response.json()
|
|
22
|
+
return json_data["data"]
|
|
23
|
+
|
|
24
|
+
def get(self, name):
|
|
25
|
+
return self._get_response(api="/get", params=dict(name=name))
|
|
26
|
+
|
|
27
|
+
def setnx(self, name, value=""):
|
|
28
|
+
return self._get_response(api="/setnx", params=dict(name=name, value=value))
|
|
29
|
+
|
|
30
|
+
def setex(self, name, t, value=""):
|
|
31
|
+
return self._get_response(api="/setex", params=dict(name=name, value=value, t=t))
|
|
32
|
+
|
|
33
|
+
def expire(self, name, t, nx: bool = False, xx: bool = False, gt: bool = False, lt: bool = False):
|
|
34
|
+
return self._get_response(api="/expire", params=dict(name=name, t=t, nx=nx, xx=xx, gt=gt, lt=lt))
|
|
35
|
+
|
|
36
|
+
def ttl(self, name):
|
|
37
|
+
return self._get_response(api="/ttl", params=dict(name=name))
|
|
38
|
+
|
|
39
|
+
def delete(self, name):
|
|
40
|
+
return self._get_response(api="/delete", params=dict(name=name))
|
|
41
|
+
|
|
42
|
+
def exists(self, name):
|
|
43
|
+
return self._get_response(api="/exists", params=dict(name=name))
|
|
44
|
+
|
|
45
|
+
def incrby(self, name, value):
|
|
46
|
+
return self._get_response(api="/incrby", params=dict(name=name, value=value))
|
|
47
|
+
|
|
48
|
+
def zcard(self, name) -> bool:
|
|
49
|
+
return self._get_response(api="/zcard", params=dict(name=name))
|
|
50
|
+
|
|
51
|
+
def zadd(self, name, item: dict, **kwargs):
|
|
52
|
+
return self._post_response(api="/zadd", data=dict(name=name, mapping=item, **kwargs))
|
|
53
|
+
|
|
54
|
+
def zrem(self, name, *values):
|
|
55
|
+
return self._post_response(api="/zrem", data=dict(name=name, values=values))
|
|
56
|
+
|
|
57
|
+
def zcount(self, name, _min, _max):
|
|
58
|
+
return self._get_response(api="/zcount", params=dict(name=name, min=_min, max=_max))
|
|
59
|
+
|
|
60
|
+
def lock(self, name, t=15) -> bool:
|
|
61
|
+
return self._get_response(api="/lock", params=dict(name=name, t=t))
|
|
62
|
+
|
|
63
|
+
def members(self, name, score, start=0, count=5000, _min="-inf", _max="+inf"):
|
|
64
|
+
return self._get_response(api="/members", params=dict(name=name, score=score, start=start, count=count, min=_min, max=_max))
|
|
65
|
+
|
|
66
|
+
def done(self, name: list, *values):
|
|
67
|
+
return self._post_response(api="/done", data=dict(name=name, values=values))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
@@ -97,7 +97,8 @@ class Launcher(threading.Thread):
|
|
|
97
97
|
self._spider_max_retries = setting.SPIDER_MAX_RETRIES
|
|
98
98
|
self._spider_thread_num = setting.SPIDER_THREAD_NUM
|
|
99
99
|
self._spider_time_sleep = setting.SPIDER_TIME_SLEEP
|
|
100
|
-
self.
|
|
100
|
+
self._spider_max_count = setting.SPIDER_MAX_COUNT
|
|
101
|
+
self._time_window = setting.TIME_WINDOW
|
|
101
102
|
|
|
102
103
|
self._done_model = setting.DONE_MODEL
|
|
103
104
|
self._task_model = setting.TASK_MODEL
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import threading
|
|
3
|
+
|
|
4
|
+
from cobweb.db import ApiDB
|
|
5
|
+
from cobweb.base import Seed, logger
|
|
6
|
+
from cobweb.constant import DealModel, LogTemplate
|
|
7
|
+
from .launcher import Launcher, check_pause
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class LauncherApi(Launcher):
|
|
11
|
+
|
|
12
|
+
def __init__(self, task, project, custom_setting=None, **kwargs):
|
|
13
|
+
super().__init__(task, project, custom_setting, **kwargs)
|
|
14
|
+
self._db = ApiDB()
|
|
15
|
+
|
|
16
|
+
self._todo_key = "{%s:%s}:todo" % (project, task)
|
|
17
|
+
self._done_key = "{%s:%s}:done" % (project, task)
|
|
18
|
+
self._fail_key = "{%s:%s}:fail" % (project, task)
|
|
19
|
+
self._heartbeat_key = "heartbeat:%s_%s" % (project, task)
|
|
20
|
+
|
|
21
|
+
self._statistics_done_key = "statistics:%s:%s:done" % (project, task)
|
|
22
|
+
self._statistics_fail_key = "statistics:%s:%s:fail" % (project, task)
|
|
23
|
+
self._speed_control_key = "speed_control:%s_%s" % (project, task)
|
|
24
|
+
|
|
25
|
+
self._reset_lock_key = "lock:reset:%s_%s" % (project, task)
|
|
26
|
+
|
|
27
|
+
# self._bf_key = "bloom_%s_%s" % (project, task)
|
|
28
|
+
# self._bf = BloomFilter(self._bf_key)
|
|
29
|
+
|
|
30
|
+
self._heartbeat_start_event = threading.Event()
|
|
31
|
+
self._redis_queue_empty_event = threading.Event()
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def heartbeat(self):
|
|
35
|
+
return self._db.exists(self._heartbeat_key)
|
|
36
|
+
|
|
37
|
+
def statistics(self, key, count):
|
|
38
|
+
if not self._task_model and not self._db.exists(key):
|
|
39
|
+
self._db.setex(key, 86400 * 30, int(count))
|
|
40
|
+
else:
|
|
41
|
+
self._db.incrby(key, count)
|
|
42
|
+
|
|
43
|
+
def _get_seed(self) -> Seed:
|
|
44
|
+
"""
|
|
45
|
+
从队列中获取种子(频控)
|
|
46
|
+
设置时间窗口为self._time_window(秒),判断在该窗口内的采集量是否满足阈值(self._spider_max_speed)
|
|
47
|
+
:return: True -> 种子, False -> None
|
|
48
|
+
"""
|
|
49
|
+
spider_speed = self._db.get(self._speed_control_key)
|
|
50
|
+
logger.info(f"spider_speed {spider_speed} seconds...")
|
|
51
|
+
if int(spider_speed or 0) > self._spider_max_count:
|
|
52
|
+
expire_time = self._db.ttl(self._speed_control_key)
|
|
53
|
+
if expire_time == -1:
|
|
54
|
+
self._db.delete(self._speed_control_key)
|
|
55
|
+
elif expire_time and expire_time > 0:
|
|
56
|
+
logger.info(f"Too fast! Please wait {expire_time} seconds...")
|
|
57
|
+
time.sleep(expire_time / 2)
|
|
58
|
+
return None
|
|
59
|
+
seed = self.__LAUNCHER_QUEUE__["todo"].pop()
|
|
60
|
+
if seed and not self._db.lock(self._speed_control_key, t=self._time_window):
|
|
61
|
+
self._db.incrby(self._speed_control_key, 1)
|
|
62
|
+
return seed
|
|
63
|
+
|
|
64
|
+
@check_pause
|
|
65
|
+
def _execute_heartbeat(self):
|
|
66
|
+
if self._heartbeat_start_event.is_set():
|
|
67
|
+
self._db.setex(self._heartbeat_key, 5)
|
|
68
|
+
time.sleep(3)
|
|
69
|
+
|
|
70
|
+
@check_pause
|
|
71
|
+
def _reset(self):
|
|
72
|
+
"""
|
|
73
|
+
检查过期种子,重新添加到redis缓存中
|
|
74
|
+
"""
|
|
75
|
+
reset_wait_seconds = 30
|
|
76
|
+
if self._db.lock(self._reset_lock_key, t=120):
|
|
77
|
+
|
|
78
|
+
_min = -int(time.time()) + self._seed_reset_seconds \
|
|
79
|
+
if self.heartbeat else "-inf"
|
|
80
|
+
|
|
81
|
+
self._db.members(self._todo_key, 0, _min=_min, _max="(0")
|
|
82
|
+
self._db.delete(self._reset_lock_key)
|
|
83
|
+
|
|
84
|
+
if not self.heartbeat:
|
|
85
|
+
self._heartbeat_start_event.set()
|
|
86
|
+
|
|
87
|
+
time.sleep(reset_wait_seconds)
|
|
88
|
+
|
|
89
|
+
@check_pause
|
|
90
|
+
def _scheduler(self):
|
|
91
|
+
"""
|
|
92
|
+
调度任务,获取redis队列种子,同时添加到doing字典中
|
|
93
|
+
"""
|
|
94
|
+
if not self._db.zcount(self._todo_key, 0, "(1000"):
|
|
95
|
+
time.sleep(self._scheduler_wait_seconds)
|
|
96
|
+
elif self.__LAUNCHER_QUEUE__['todo'].length >= self._todo_queue_size:
|
|
97
|
+
time.sleep(self._todo_queue_full_wait_seconds)
|
|
98
|
+
else:
|
|
99
|
+
members = self._db.members(
|
|
100
|
+
self._todo_key, int(time.time()),
|
|
101
|
+
count=self._todo_queue_size,
|
|
102
|
+
_min=0, _max="(1000"
|
|
103
|
+
)
|
|
104
|
+
for member, priority in members:
|
|
105
|
+
seed = Seed(member, priority=priority)
|
|
106
|
+
self.__LAUNCHER_QUEUE__['todo'].push(seed)
|
|
107
|
+
self.__DOING__[seed.to_string] = seed.params.priority
|
|
108
|
+
|
|
109
|
+
@check_pause
|
|
110
|
+
def _insert(self):
|
|
111
|
+
"""
|
|
112
|
+
添加新种子到redis队列中
|
|
113
|
+
"""
|
|
114
|
+
seeds = {}
|
|
115
|
+
status = self.__LAUNCHER_QUEUE__['new'].length < self._new_queue_max_size
|
|
116
|
+
for _ in range(self._new_queue_max_size):
|
|
117
|
+
seed = self.__LAUNCHER_QUEUE__['new'].pop()
|
|
118
|
+
if seed:
|
|
119
|
+
seeds[seed.to_string] = seed.params.priority
|
|
120
|
+
if seeds:
|
|
121
|
+
self._db.zadd(self._todo_key, seeds, nx=True)
|
|
122
|
+
if status:
|
|
123
|
+
time.sleep(self._new_queue_wait_seconds)
|
|
124
|
+
|
|
125
|
+
@check_pause
|
|
126
|
+
def _refresh(self):
|
|
127
|
+
"""
|
|
128
|
+
刷新doing种子过期时间,防止reset重新消费
|
|
129
|
+
"""
|
|
130
|
+
if self.__DOING__:
|
|
131
|
+
refresh_time = int(time.time())
|
|
132
|
+
seeds = {k:-refresh_time - v / 1000 for k, v in self.__DOING__.items()}
|
|
133
|
+
self._db.zadd(self._todo_key, item=seeds, xx=True)
|
|
134
|
+
time.sleep(15)
|
|
135
|
+
|
|
136
|
+
@check_pause
|
|
137
|
+
def _delete(self):
|
|
138
|
+
"""
|
|
139
|
+
删除队列种子,根据状态添加至成功或失败队列,移除doing字典种子索引
|
|
140
|
+
"""
|
|
141
|
+
seed_info = {"count": 0, "failed": [], "succeed": [], "common": []}
|
|
142
|
+
status = self.__LAUNCHER_QUEUE__['done'].length < self._done_queue_max_size
|
|
143
|
+
|
|
144
|
+
for _ in range(self._done_queue_max_size):
|
|
145
|
+
seed = self.__LAUNCHER_QUEUE__['done'].pop()
|
|
146
|
+
if not seed:
|
|
147
|
+
break
|
|
148
|
+
if seed.params.seed_status == DealModel.fail:
|
|
149
|
+
seed_info["failed"].append(seed.to_string)
|
|
150
|
+
elif self._done_model == 1:
|
|
151
|
+
seed_info["succeed"].append(seed.to_string)
|
|
152
|
+
else:
|
|
153
|
+
seed_info["common"].append(seed.to_string)
|
|
154
|
+
seed_info['count'] += 1
|
|
155
|
+
|
|
156
|
+
if seed_info["count"]:
|
|
157
|
+
|
|
158
|
+
succeed_count = self._db.zrem(self._todo_key, *seed_info["common"])
|
|
159
|
+
succeed_count += self._db.done([self._todo_key, self._done_key], *seed_info["succeed"])
|
|
160
|
+
failed_count = self._db.done([self._todo_key, self._fail_key], *seed_info["failed"])
|
|
161
|
+
|
|
162
|
+
if failed_count:
|
|
163
|
+
self.statistics(self._statistics_fail_key, failed_count)
|
|
164
|
+
if succeed_count:
|
|
165
|
+
self.statistics(self._statistics_done_key, succeed_count)
|
|
166
|
+
|
|
167
|
+
self._remove_doing_seeds(seed_info["common"] + seed_info["succeed"] + seed_info["failed"])
|
|
168
|
+
|
|
169
|
+
if status:
|
|
170
|
+
time.sleep(self._done_queue_wait_seconds)
|
|
171
|
+
|
|
172
|
+
def _polling(self):
|
|
173
|
+
wait_scheduler_execute = True
|
|
174
|
+
check_emtpy_times = 0
|
|
175
|
+
while not self._stop.is_set():
|
|
176
|
+
queue_not_empty_count = 0
|
|
177
|
+
pooling_wait_seconds = 30
|
|
178
|
+
|
|
179
|
+
for q in self.__LAUNCHER_QUEUE__.values():
|
|
180
|
+
if q.length != 0:
|
|
181
|
+
queue_not_empty_count += 1
|
|
182
|
+
wait_scheduler_execute = False
|
|
183
|
+
|
|
184
|
+
if queue_not_empty_count == 0:
|
|
185
|
+
pooling_wait_seconds = 3
|
|
186
|
+
if self._pause.is_set():
|
|
187
|
+
check_emtpy_times = 0
|
|
188
|
+
if not self._task_model and (
|
|
189
|
+
not wait_scheduler_execute or
|
|
190
|
+
int(time.time()) - self._app_time > self._before_scheduler_wait_seconds
|
|
191
|
+
):
|
|
192
|
+
logger.info("Done! ready to close thread...")
|
|
193
|
+
self._stop.set()
|
|
194
|
+
|
|
195
|
+
elif self._db.zcount(self._todo_key, _min=0, _max="(1000"):
|
|
196
|
+
logger.info(f"Recovery {self.task} task run!")
|
|
197
|
+
self._pause.clear()
|
|
198
|
+
self._execute()
|
|
199
|
+
else:
|
|
200
|
+
logger.info("pause! waiting for resume...")
|
|
201
|
+
elif check_emtpy_times > 2:
|
|
202
|
+
self.__DOING__ = {}
|
|
203
|
+
if not self._db.zcount(self._todo_key, _min="-inf", _max="(1000"):
|
|
204
|
+
self._pause.set()
|
|
205
|
+
else:
|
|
206
|
+
logger.info(
|
|
207
|
+
"check whether the task is complete, "
|
|
208
|
+
f"reset times {3 - check_emtpy_times}"
|
|
209
|
+
)
|
|
210
|
+
check_emtpy_times += 1
|
|
211
|
+
else:
|
|
212
|
+
logger.info(LogTemplate.launcher_pro_polling.format(
|
|
213
|
+
task=self.task,
|
|
214
|
+
doing_len=len(self.__DOING__.keys()),
|
|
215
|
+
todo_len=self.__LAUNCHER_QUEUE__['todo'].length,
|
|
216
|
+
done_len=self.__LAUNCHER_QUEUE__['done'].length,
|
|
217
|
+
redis_seed_count=self._db.zcount(self._todo_key, "-inf", "+inf"),
|
|
218
|
+
redis_todo_len=self._db.zcount(self._todo_key, 0, "(1000"),
|
|
219
|
+
redis_doing_len=self._db.zcount(self._todo_key, "-inf", "(0"),
|
|
220
|
+
upload_len=self.__LAUNCHER_QUEUE__['upload'].length,
|
|
221
|
+
))
|
|
222
|
+
|
|
223
|
+
time.sleep(pooling_wait_seconds)
|
|
224
|
+
|
|
225
|
+
logger.info("Done! Ready to close thread...")
|
|
226
|
+
|
|
@@ -44,7 +44,7 @@ class LauncherPro(Launcher):
|
|
|
44
44
|
|
|
45
45
|
def _get_seed(self) -> Seed:
|
|
46
46
|
spider_speed = self._db._client.get(self._speed_control_key)
|
|
47
|
-
if int(spider_speed or 0) > self.
|
|
47
|
+
if int(spider_speed or 0) > self._spider_max_count:
|
|
48
48
|
expire_time = self._db.ttl(self._speed_control_key)
|
|
49
49
|
if expire_time == -1:
|
|
50
50
|
self._db.delete(self._speed_control_key)
|
|
@@ -53,7 +53,7 @@ class LauncherPro(Launcher):
|
|
|
53
53
|
time.sleep(expire_time / 2)
|
|
54
54
|
return None
|
|
55
55
|
seed = self.__LAUNCHER_QUEUE__["todo"].pop()
|
|
56
|
-
if seed and not self._db.lock(self._speed_control_key, t=
|
|
56
|
+
if seed and not self._db.lock(self._speed_control_key, t=self._time_window):
|
|
57
57
|
self._db._client.incrby(self._speed_control_key, 1)
|
|
58
58
|
return seed
|
|
59
59
|
|
|
@@ -58,7 +58,9 @@ DONE_MODEL = 0 # 0:种子消费成功直接从队列移除,失败则添加
|
|
|
58
58
|
SPIDER_THREAD_NUM = 10
|
|
59
59
|
SPIDER_MAX_RETRIES = 5
|
|
60
60
|
SPIDER_TIME_SLEEP = 10
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
SPIDER_MAX_COUNT = 1000 # 在规定时间窗口内最大采集数
|
|
63
|
+
TIME_WINDOW = 60 # 频控固定时间窗口(秒)
|
|
62
64
|
|
|
63
65
|
# 任务模式
|
|
64
66
|
TASK_MODEL = 0 # 0:单次,1:常驻
|
|
@@ -15,12 +15,14 @@ cobweb/base/seed.py
|
|
|
15
15
|
cobweb/crawlers/__init__.py
|
|
16
16
|
cobweb/crawlers/crawler.py
|
|
17
17
|
cobweb/db/__init__.py
|
|
18
|
+
cobweb/db/api_db.py
|
|
18
19
|
cobweb/db/redis_db.py
|
|
19
20
|
cobweb/exceptions/__init__.py
|
|
20
21
|
cobweb/exceptions/oss_db_exception.py
|
|
21
22
|
cobweb/launchers/__init__.py
|
|
22
23
|
cobweb/launchers/launcher.py
|
|
23
24
|
cobweb/launchers/launcher_air.py
|
|
25
|
+
cobweb/launchers/launcher_api.py
|
|
24
26
|
cobweb/launchers/launcher_pro.py
|
|
25
27
|
cobweb/pipelines/__init__.py
|
|
26
28
|
cobweb/pipelines/pipeline.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cobweb-launcher-1.2.15 → cobweb-launcher-1.2.16}/cobweb_launcher.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|