cobweb-launcher 1.2.49__py3-none-any.whl → 1.2.51__py3-none-any.whl
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.
Potentially problematic release.
This version of cobweb-launcher might be problematic. Click here for more details.
- cobweb/base/seed.py +10 -2
- cobweb/crawlers/crawler.py +5 -3
- cobweb/launchers/launcher.py +1 -0
- cobweb/launchers/launcher_api.py +1 -1
- cobweb/launchers/launcher_pro.py +12 -11
- cobweb/setting.py +2 -0
- cobweb/utils/dotting.py +0 -9
- {cobweb_launcher-1.2.49.dist-info → cobweb_launcher-1.2.51.dist-info}/METADATA +1 -1
- {cobweb_launcher-1.2.49.dist-info → cobweb_launcher-1.2.51.dist-info}/RECORD +12 -12
- {cobweb_launcher-1.2.49.dist-info → cobweb_launcher-1.2.51.dist-info}/LICENSE +0 -0
- {cobweb_launcher-1.2.49.dist-info → cobweb_launcher-1.2.51.dist-info}/WHEEL +0 -0
- {cobweb_launcher-1.2.49.dist-info → cobweb_launcher-1.2.51.dist-info}/top_level.txt +0 -0
cobweb/base/seed.py
CHANGED
|
@@ -5,11 +5,13 @@ import hashlib
|
|
|
5
5
|
|
|
6
6
|
class SeedParams:
|
|
7
7
|
|
|
8
|
-
def __init__(self, retry, priority, seed_version, seed_status=None):
|
|
8
|
+
def __init__(self, retry, priority, seed_version, seed_status=None, proxy_type=None, proxy=None):
|
|
9
9
|
self.retry = retry or 0
|
|
10
10
|
self.priority = priority or 300
|
|
11
11
|
self.seed_version = seed_version or int(time.time())
|
|
12
12
|
self.seed_status = seed_status
|
|
13
|
+
self.proxy_type = proxy_type
|
|
14
|
+
self.proxy = proxy
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
class Seed:
|
|
@@ -18,7 +20,9 @@ class Seed:
|
|
|
18
20
|
"retry",
|
|
19
21
|
"priority",
|
|
20
22
|
"seed_version",
|
|
21
|
-
"seed_status"
|
|
23
|
+
"seed_status",
|
|
24
|
+
"proxy_type",
|
|
25
|
+
"proxy"
|
|
22
26
|
]
|
|
23
27
|
|
|
24
28
|
def __init__(
|
|
@@ -29,6 +33,8 @@ class Seed:
|
|
|
29
33
|
priority=None,
|
|
30
34
|
seed_version=None,
|
|
31
35
|
seed_status=None,
|
|
36
|
+
proxy_type=None,
|
|
37
|
+
proxy=None,
|
|
32
38
|
**kwargs
|
|
33
39
|
):
|
|
34
40
|
if any(isinstance(seed, t) for t in (str, bytes)):
|
|
@@ -51,6 +57,8 @@ class Seed:
|
|
|
51
57
|
"priority": priority,
|
|
52
58
|
"seed_version": seed_version,
|
|
53
59
|
"seed_status": seed_status,
|
|
60
|
+
"proxy_type": proxy_type,
|
|
61
|
+
"proxy": proxy
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
if kwargs:
|
cobweb/crawlers/crawler.py
CHANGED
|
@@ -19,7 +19,6 @@ from cobweb.base import (
|
|
|
19
19
|
logger
|
|
20
20
|
)
|
|
21
21
|
from cobweb.utils import LoghubDot
|
|
22
|
-
proxy_type = os.getenv("PROXY_TYPE", "")
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
class Crawler(threading.Thread):
|
|
@@ -149,7 +148,9 @@ class Crawler(threading.Thread):
|
|
|
149
148
|
topic=urlparse(download_item.response.request.url).netloc,
|
|
150
149
|
data_size=int(download_item.response.headers.get("content-length", 0)),
|
|
151
150
|
cost_time=end_time - start_time, status = 200,
|
|
152
|
-
url=download_item.response.url,
|
|
151
|
+
url=download_item.response.url,
|
|
152
|
+
proxy_type=seed.params.proxy_type,
|
|
153
|
+
proxy=seed.params.proxy,
|
|
153
154
|
project=self.project, task=self.task,
|
|
154
155
|
)
|
|
155
156
|
parse_iterators = self.parse(download_item)
|
|
@@ -178,7 +179,8 @@ class Crawler(threading.Thread):
|
|
|
178
179
|
topic=urlparse(url).netloc,
|
|
179
180
|
data_size=-1, cost_time=-1,
|
|
180
181
|
status=status, url=url,
|
|
181
|
-
proxy_type=proxy_type,
|
|
182
|
+
proxy_type=seed.params.proxy_type,
|
|
183
|
+
proxy=seed.params.proxy,
|
|
182
184
|
project=self.project,
|
|
183
185
|
task=self.task,
|
|
184
186
|
msg=exception_msg,
|
cobweb/launchers/launcher.py
CHANGED
|
@@ -100,6 +100,7 @@ class Launcher(threading.Thread):
|
|
|
100
100
|
self._spider_time_sleep = setting.SPIDER_TIME_SLEEP
|
|
101
101
|
self._spider_max_count = setting.SPIDER_MAX_COUNT
|
|
102
102
|
self._time_window = setting.TIME_WINDOW
|
|
103
|
+
self._speed_control = setting.SPEED_CONTROL
|
|
103
104
|
|
|
104
105
|
self._done_model = setting.DONE_MODEL
|
|
105
106
|
self._task_model = setting.TASK_MODEL
|
cobweb/launchers/launcher_api.py
CHANGED
|
@@ -46,7 +46,7 @@ class LauncherApi(Launcher):
|
|
|
46
46
|
设置时间窗口为self._time_window(秒),判断在该窗口内的采集量是否满足阈值(self._spider_max_speed)
|
|
47
47
|
:return: True -> 种子, False -> None
|
|
48
48
|
"""
|
|
49
|
-
if (self.__LAUNCHER_QUEUE__["todo"].length and
|
|
49
|
+
if (self._speed_control and self.__LAUNCHER_QUEUE__["todo"].length and
|
|
50
50
|
not self._db.auto_incr(self._speed_control_key, t=self._time_window, limit=self._spider_max_count)):
|
|
51
51
|
expire_time = self._db.ttl(self._speed_control_key)
|
|
52
52
|
logger.info(f"Too fast! Please wait {expire_time} seconds...")
|
cobweb/launchers/launcher_pro.py
CHANGED
|
@@ -3,7 +3,7 @@ import threading
|
|
|
3
3
|
|
|
4
4
|
from cobweb.db import RedisDB
|
|
5
5
|
from cobweb.base import Seed, logger
|
|
6
|
-
from cobweb.utils import BloomFilter
|
|
6
|
+
# from cobweb.utils import BloomFilter
|
|
7
7
|
from cobweb.constant import DealModel, LogTemplate
|
|
8
8
|
from .launcher import Launcher, check_pause
|
|
9
9
|
|
|
@@ -43,17 +43,18 @@ class LauncherPro(Launcher):
|
|
|
43
43
|
self._db._client.incrby(key, count)
|
|
44
44
|
|
|
45
45
|
def _get_seed(self) -> Seed:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
if self._speed_control:
|
|
47
|
+
spider_speed = self._db._client.get(self._speed_control_key)
|
|
48
|
+
if int(spider_speed or 0) > self._spider_max_count:
|
|
49
|
+
expire_time = self._db.ttl(self._speed_control_key)
|
|
50
|
+
if expire_time == -1:
|
|
51
|
+
self._db.delete(self._speed_control_key)
|
|
52
|
+
else:
|
|
53
|
+
logger.info(f"Too fast! Please wait {expire_time} seconds...")
|
|
54
|
+
time.sleep(expire_time / 2)
|
|
55
|
+
return None
|
|
55
56
|
seed = self.__LAUNCHER_QUEUE__["todo"].pop()
|
|
56
|
-
if seed and not self._db.lock(self._speed_control_key, t=self._time_window):
|
|
57
|
+
if self._speed_control and seed and not self._db.lock(self._speed_control_key, t=self._time_window):
|
|
57
58
|
self._db._client.incrby(self._speed_control_key, 1)
|
|
58
59
|
return seed
|
|
59
60
|
|
cobweb/setting.py
CHANGED
cobweb/utils/dotting.py
CHANGED
|
@@ -24,16 +24,7 @@ class LoghubDot:
|
|
|
24
24
|
temp[key] = value
|
|
25
25
|
contents = sorted(temp.items())
|
|
26
26
|
log_item.set_contents(contents)
|
|
27
|
-
# log_items.append(log_item)
|
|
28
|
-
# request = PutLogsRequest(
|
|
29
|
-
# project="databee-download-log",
|
|
30
|
-
# logstore="log",
|
|
31
|
-
# topic=topic,
|
|
32
|
-
# logitems=log_items,
|
|
33
|
-
# compress=True
|
|
34
|
-
# )
|
|
35
27
|
self.queue.push((topic, log_item), direct_insertion=True)
|
|
36
|
-
# self.client.put_logs(request=request)
|
|
37
28
|
|
|
38
29
|
def build_run(self):
|
|
39
30
|
while True:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cobweb/__init__.py,sha256=CBd2oByCfc5EmH2dCZYVHkxXYZG-oWrLyTtZU5sEoP0,96
|
|
2
2
|
cobweb/constant.py,sha256=zy3XYsc1qp2B76_Fn_hVQ8eGHlPBd3OFlZK2cryE6FY,2839
|
|
3
|
-
cobweb/setting.py,sha256=
|
|
3
|
+
cobweb/setting.py,sha256=JHRrVQL22iidkNe8seQTuxK3hlTdtnvb6VBVygpMs5I,2272
|
|
4
4
|
cobweb/base/__init__.py,sha256=4gwWWQ0Q8cYG9cD7Lwf4XMqRGc5M_mapS3IczR6zeCE,222
|
|
5
5
|
cobweb/base/basic.py,sha256=Z56SSLB3I2IGHWCCcSy0Qbfzj8Qbg_po3gP32q1jh4k,7741
|
|
6
6
|
cobweb/base/common_queue.py,sha256=W7PPZZFl52j3Mc916T0imHj7oAUelA6aKJwW-FecDPE,872
|
|
@@ -10,10 +10,10 @@ cobweb/base/item.py,sha256=hYheVTV2Bozp4iciJpE2ZwBIXkaqBg4QQkRccP8yoVk,1049
|
|
|
10
10
|
cobweb/base/log.py,sha256=L01hXdk3L2qEm9X1FOXQ9VmWIoHSELe0cyZvrdAN61A,2003
|
|
11
11
|
cobweb/base/request.py,sha256=tEkgMVUfdQI-kZuzWuiit9P_q4Q9-_RZh9aXXpc0314,2352
|
|
12
12
|
cobweb/base/response.py,sha256=eB1DWMXFCpn3cJ3yzgCRU1WeZAdayGDohRgdjdMUFN4,406
|
|
13
|
-
cobweb/base/seed.py,sha256=
|
|
13
|
+
cobweb/base/seed.py,sha256=A-F1urjbE5hYNWTCwq3sUV4nrxlK_RGMoCmjBmIwYsI,3158
|
|
14
14
|
cobweb/crawlers/__init__.py,sha256=msvkB9mTpsgyj8JfNMsmwAcpy5kWk_2NrO1Adw2Hkw0,29
|
|
15
15
|
cobweb/crawlers/base_crawler.py,sha256=ee_WSDnPQpPTk6wlFuY2UEx5L3hcsAZFcr6i3GLSry8,5751
|
|
16
|
-
cobweb/crawlers/crawler.py,sha256=
|
|
16
|
+
cobweb/crawlers/crawler.py,sha256=pePDGroD6JJAht5QTU51L7MkFIY4ob9TKpznZ2wUmsw,8965
|
|
17
17
|
cobweb/crawlers/file_crawler.py,sha256=2Sjbdgxzqd41WykKUQE3QQlGai3T8k-pmHNmPlTchjQ,4454
|
|
18
18
|
cobweb/db/__init__.py,sha256=uZwSkd105EAwYo95oZQXAfofUKHVIAZZIPpNMy-hm2Q,56
|
|
19
19
|
cobweb/db/api_db.py,sha256=bDc5dJQxq4z04h70KUTHd0OqUOEY7Cm3wcNJZtTvJIM,3015
|
|
@@ -21,10 +21,10 @@ cobweb/db/redis_db.py,sha256=fumNZJiio-uQqRcSrymx8eJ1PqsdOwITe_Y-9JOXxrQ,4298
|
|
|
21
21
|
cobweb/exceptions/__init__.py,sha256=E9SHnJBbhD7fOgPFMswqyOf8SKRDrI_i25L0bSpohvk,32
|
|
22
22
|
cobweb/exceptions/oss_db_exception.py,sha256=iP_AImjNHT3-Iv49zCFQ3rdLnlvuHa3h2BXApgrOYpA,636
|
|
23
23
|
cobweb/launchers/__init__.py,sha256=qMuVlQcjErVK67HyKFZEsXf_rfZD5ODjx1QucSCKMOM,114
|
|
24
|
-
cobweb/launchers/launcher.py,sha256=
|
|
24
|
+
cobweb/launchers/launcher.py,sha256=_qC3EnD_QxQRP_RBNHHJ8HLfn_0FED1jUF_lyas5Hss,7081
|
|
25
25
|
cobweb/launchers/launcher_air.py,sha256=KAk_M8F3029cXYe7m4nn3Nzyi89lbxJ2cqZjqW8iZ0E,2832
|
|
26
|
-
cobweb/launchers/launcher_api.py,sha256=
|
|
27
|
-
cobweb/launchers/launcher_pro.py,sha256=
|
|
26
|
+
cobweb/launchers/launcher_api.py,sha256=7K7Kl3dk7Ung9iRBwhiMrALEJywcR66ie5RIkLQEM-Y,7909
|
|
27
|
+
cobweb/launchers/launcher_pro.py,sha256=QMumHUTi6IudO5mw9SnwlmP8k_BJ50cpNjYjoQv-_YY,7936
|
|
28
28
|
cobweb/pipelines/__init__.py,sha256=zSUsGtx6smbs2iXBXvYynReKSgky-3gjqaAtKVnA_OU,105
|
|
29
29
|
cobweb/pipelines/pipeline.py,sha256=4TJLX0sUHRxYndF5A4Vs5btUGI-wigkOcFvhTW1hLXI,2009
|
|
30
30
|
cobweb/pipelines/pipeline_console.py,sha256=NEh-4zhuVAQOqwXLsqeb-rcNZ9_KXFUpL3otUTL5qBs,754
|
|
@@ -34,11 +34,11 @@ cobweb/schedulers/scheduler_api.py,sha256=pFEdS1H4zuzxwMhCV-G7CoLz-rEOPv4EVo3xZU
|
|
|
34
34
|
cobweb/schedulers/scheduler_redis.py,sha256=E5fjc3nNld8GbUhUGT7uY4smRejj2J2ZIzp2g6lhxFM,2205
|
|
35
35
|
cobweb/utils/__init__.py,sha256=Ev2LZZ1-S56iQYDqFZrqadizEv4Gk8Of-DraH-_WnKY,109
|
|
36
36
|
cobweb/utils/bloom.py,sha256=vng-YbKgh9HbtpAWYf_nkUSbfVTOj40aqUUejRYlsCU,1752
|
|
37
|
-
cobweb/utils/dotting.py,sha256=
|
|
37
|
+
cobweb/utils/dotting.py,sha256=mVICaa26R-dQ4JGmPK-kkR6QjX38QiRewXZnGb2DCIc,1784
|
|
38
38
|
cobweb/utils/oss.py,sha256=gyt8-UB07tVphZLQXMOf-JTJwU-mWq8KZkOXKkAf3uk,3513
|
|
39
39
|
cobweb/utils/tools.py,sha256=5JEaaAwYoV9Sdla2UBIJn6faUBuXmxUMagm9ck6FVqs,1253
|
|
40
|
-
cobweb_launcher-1.2.
|
|
41
|
-
cobweb_launcher-1.2.
|
|
42
|
-
cobweb_launcher-1.2.
|
|
43
|
-
cobweb_launcher-1.2.
|
|
44
|
-
cobweb_launcher-1.2.
|
|
40
|
+
cobweb_launcher-1.2.51.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
|
|
41
|
+
cobweb_launcher-1.2.51.dist-info/METADATA,sha256=xzLg7vLTsWurDo9L8jjmnlq-8B6UE1bT2itXPHt4a8o,6510
|
|
42
|
+
cobweb_launcher-1.2.51.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
43
|
+
cobweb_launcher-1.2.51.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
|
|
44
|
+
cobweb_launcher-1.2.51.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|