bricks-py 0.0.2__tar.gz → 0.0.3__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.
Files changed (42) hide show
  1. {bricks-py-0.0.2 → bricks-py-0.0.3}/PKG-INFO +1 -1
  2. {bricks-py-0.0.2 → bricks-py-0.0.3}/README.md +1 -1
  3. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/const.py +1 -1
  4. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/proxies.py +1 -0
  5. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/utils/pandora.py +6 -6
  6. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks_py.egg-info/PKG-INFO +1 -1
  7. {bricks-py-0.0.2 → bricks-py-0.0.3}/demos/air_spider_demo.py +19 -19
  8. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/__init__.py +0 -0
  9. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/core/__init__.py +0 -0
  10. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/core/dispatch.py +0 -0
  11. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/core/events.py +0 -0
  12. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/core/genesis.py +0 -0
  13. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/core/signals.py +0 -0
  14. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/db/__init__.py +0 -0
  15. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/db/redis_.py +0 -0
  16. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/db/sqllite.py +0 -0
  17. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/downloader/__init__.py +0 -0
  18. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/downloader/cffi.py +0 -0
  19. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/downloader/genesis.py +0 -0
  20. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/__init__.py +0 -0
  21. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/context.py +0 -0
  22. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/counter.py +0 -0
  23. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/extractors.py +0 -0
  24. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/headers.py +0 -0
  25. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/items.py +0 -0
  26. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/queues.py +0 -0
  27. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/request.py +0 -0
  28. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/lib/response.py +0 -0
  29. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/plugins.py +0 -0
  30. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/spider/__init__.py +0 -0
  31. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/spider/air.py +0 -0
  32. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/spider/form.py +0 -0
  33. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks/utils/__init__.py +0 -0
  34. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks_py.egg-info/SOURCES.txt +0 -0
  35. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks_py.egg-info/dependency_links.txt +0 -0
  36. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks_py.egg-info/requires.txt +0 -0
  37. {bricks-py-0.0.2 → bricks-py-0.0.3}/bricks_py.egg-info/top_level.txt +0 -0
  38. {bricks-py-0.0.2 → bricks-py-0.0.3}/demos/__init__.py +0 -0
  39. {bricks-py-0.0.2 → bricks-py-0.0.3}/demos/dispatcher_test.py +0 -0
  40. {bricks-py-0.0.2 → bricks-py-0.0.3}/demos/form_spider_demo.py +0 -0
  41. {bricks-py-0.0.2 → bricks-py-0.0.3}/setup.cfg +0 -0
  42. {bricks-py-0.0.2 → bricks-py-0.0.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bricks-py
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: quickly build your crawler
5
5
  Author: Kem
6
6
  Author-email: 531144129@qq.com
@@ -16,7 +16,7 @@ Bricks 拥有以下特性
16
16
  安装
17
17
 
18
18
  ```
19
- pip install bricks-py==0.0.1
19
+ pip install bricks-py
20
20
  ```
21
21
 
22
22
  # 简单上手
@@ -9,7 +9,7 @@ import uuid
9
9
  MACHINE_ID = hashlib.sha256(uuid.UUID(int=uuid.getnode()).hex[-12:].encode()).hexdigest()
10
10
 
11
11
  # 当前框架版本
12
- VERSION = "0.0.2"
12
+ VERSION = "0.0.3"
13
13
 
14
14
  # 事件类型
15
15
  ERROR_OCCURRED = 'ERROR_OCCURRED'
@@ -35,6 +35,7 @@ class MetaClass(type):
35
35
  def __new__(cls, name, bases, dct): # noqa
36
36
  def wrapper(raw_method):
37
37
  def inner(self, *args, **kwargs):
38
+ self: BaseProxy
38
39
  proxy = raw_method(self, *args, **kwargs)
39
40
  proxy.proxy = self.fmt(proxy=proxy.proxy)
40
41
  proxy.auth = self.auth
@@ -116,6 +116,10 @@ def prepare(func, args=None, kwargs: dict = None, annotations: dict = None, name
116
116
  if name in kwargs:
117
117
  value = kwargs[name]
118
118
 
119
+ # 参数在 namespace 里面 -> 从 namespace 里面取
120
+ elif param.name in namespace:
121
+ value = namespace[param.name]
122
+
119
123
  # 参数类型存在于 annotations, 并且还可以从 args 里面取值, 并且刚好取到的对应的值也是当前类型 -> 直接从 args 里面取
120
124
  elif param.annotation in annotations and index < len(args) and type(args[index]) == param.annotation:
121
125
  value = args[index]
@@ -130,20 +134,16 @@ def prepare(func, args=None, kwargs: dict = None, annotations: dict = None, name
130
134
  value = args[index]
131
135
  index += 1
132
136
 
133
- elif param.name in namespace:
134
-
135
- value = namespace[param.name]
136
-
137
137
  elif param.default != inspect.Parameter.empty:
138
138
  continue
139
139
 
140
140
  # 没有传这个参数, 并且也没有可以备选的 annotations -> 报错
141
141
  else:
142
142
  raise TypeError(f"missing required argument: {name}, signature: {dict(parameters)}")
143
- if param.kind in [inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD]:
143
+ if param.kind in [inspect.Parameter.POSITIONAL_ONLY]:
144
144
  new_args.append(value)
145
145
 
146
- if param.kind == inspect.Parameter.KEYWORD_ONLY:
146
+ if param.kind in [inspect.Parameter.KEYWORD_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD]:
147
147
  new_kwargs[name] = value
148
148
 
149
149
  return prepared(func=func, args=new_args, kwargs=new_kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bricks-py
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: quickly build your crawler
5
5
  Author: Kem
6
6
  Author-email: 531144129@qq.com
@@ -85,27 +85,27 @@ if __name__ == '__main__':
85
85
  spider = MySpider(
86
86
  # # 设置代理模式 1, 该模式适用于: 你已经将代理提取至 Redis 的 proxy 里面
87
87
  # # 这样设置的话就会自动去取
88
- # proxy={
89
- # "ref": "bricks.lib.proxies.RedisProxy", # 指向 Redis
90
- # "key": "proxy", # 指向代理 Key
91
- # # 这个不写默认指向本地 Redis, 无密码的
92
- # "options": {
93
- # "host": "127.0.0.1",
94
- # "port": 6379,
95
- # "password": "xsxsxax"
96
- # },
97
- # "threshold": 100, # 一个代理最多使用多少次, 到这个次数之后就会归还到Redis, 然后重新拿, 默认不归还
98
- # "scheme": "socks5" # 代理协议, 默认是 http
99
- # }
100
-
101
- # 设置代理模式 2, 该模式适用于: 指向固定代理, 如 http://127.0.0.1:7890
102
- # 这样设置的话就会自动去取
103
88
  proxy={
104
- "ref": "bricks.lib.proxies.CustomProxy", # 指向 Redis
105
- "key": "127.0.0.1:7890", # 指向代理 Key
89
+ "ref": "bricks.lib.proxies.RedisProxy", # 指向 Redis
90
+ "key": "proxy", # 指向代理 Key
91
+ # 这个不写默认指向本地 Redis, 无密码的
92
+ "options": {
93
+ "host": "127.0.0.1",
94
+ "port": 6379,
95
+ # "password": "xsxsxax"
96
+ },
106
97
  "threshold": 100, # 一个代理最多使用多少次, 到这个次数之后就会归还到Redis, 然后重新拿, 默认不归还
107
- "scheme": "http" # 代理协议, 默认是 http
108
- },
98
+ "scheme": "socks5" # 代理协议, 默认是 http
99
+ }
100
+
101
+ # # 设置代理模式 2, 该模式适用于: 指向固定代理, 如 http://127.0.0.1:7890
102
+ # # 这样设置的话就会自动去取
103
+ # proxy={
104
+ # "ref": "bricks.lib.proxies.CustomProxy", # 指向 Redis
105
+ # "key": "127.0.0.1:7890", # 指向代理 Key
106
+ # "threshold": 100, # 一个代理最多使用多少次, 到这个次数之后就会归还到Redis, 然后重新拿, 默认不归还
107
+ # # "scheme": "http" # 代理协议, 默认是 http
108
+ # },
109
109
 
110
110
  # # 设置代理模式 3, 该模式适用于: 你有一个提取 api,访问就会获取代理
111
111
  # # 这样设置的话就会自动去取
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes