coocan 0.3__tar.gz → 0.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coocan
3
- Version: 0.3
3
+ Version: 0.3.2
4
4
  Summary: Air Spider Framework
5
5
  Author: wauo
6
6
  Author-email: markadc@126.com
@@ -0,0 +1 @@
1
+ from coocan.spider.base import MiniSpider
@@ -7,7 +7,7 @@ import coocan
7
7
  from coocan.url import Request
8
8
 
9
9
 
10
- class AirAsyncSpider:
10
+ class MiniSpider:
11
11
  start_urls = []
12
12
  max_requests = 5
13
13
 
@@ -17,5 +17,10 @@ class Request:
17
17
  self.cb_kwargs = cb_kwargs or {}
18
18
 
19
19
  async def send(self):
20
- response = await cli.get(self.url, params=self.params, headers=self.headers, timeout=self.timeout)
20
+ if (self.data and self.json) is None:
21
+ response = await cli.get(self.url, params=self.params, headers=self.headers, timeout=self.timeout)
22
+ elif self.data or self.json:
23
+ response = await cli.post(self.url, params=self.params, headers=self.headers, data=self.data, json=self.json, timeout=self.timeout)
24
+ else:
25
+ raise Exception("仅支持 GET 和 POST 请求")
21
26
  return response
@@ -37,7 +37,7 @@ class SelectorResponse(Response):
37
37
  if self.status_code not in codes:
38
38
  raise ResponseCodeError("{} not in {}".format(self.status_code, codes))
39
39
 
40
- def raise_for_text(self, validate: Callable[[str], bool] = None):
40
+ def raise_for_text(self, validate: Callable[[str], bool]):
41
41
  if validate(self.text) is False:
42
42
  raise ResponseTextError("not ideal text")
43
43
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coocan
3
- Version: 0.3
3
+ Version: 0.3.2
4
4
  Summary: Air Spider Framework
5
5
  Author: wauo
6
6
  Author-email: markadc@126.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="coocan",
5
- version="0.3",
5
+ version="0.3.2",
6
6
  author="wauo",
7
7
  author_email="markadc@126.com",
8
8
  description="Air Spider Framework",
@@ -1 +0,0 @@
1
- from coocan.spider.base import AirAsyncSpider
File without changes
File without changes
File without changes
File without changes