coocan 0.5.6__tar.gz → 0.5.6.1__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.
- {coocan-0.5.6 → coocan-0.5.6.1}/PKG-INFO +1 -4
- coocan-0.5.6.1/coocan/_examples/use_proxy.py +22 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/push_project.py +1 -1
- coocan-0.5.6.1/coocan/url/request.py +46 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan.egg-info/PKG-INFO +1 -4
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan.egg-info/SOURCES.txt +1 -1
- {coocan-0.5.6 → coocan-0.5.6.1}/pyproject.toml +1 -1
- coocan-0.5.6/coocan/url/request.py +0 -31
- coocan-0.5.6/setup.py +0 -30
- {coocan-0.5.6 → coocan-0.5.6.1}/README.md +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/__init__.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/_examples/crawl_csdn_detail.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/_examples/crawl_csdn_list.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/_examples/recv_item.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/_examples/view_local_ip.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/cmd/__init__.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/cmd/cli.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/gen.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/spider/__init__.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/spider/base.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/templates/spider.txt +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/url/__init__.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan/url/response.py +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan.egg-info/dependency_links.txt +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan.egg-info/entry_points.txt +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan.egg-info/requires.txt +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/coocan.egg-info/top_level.txt +0 -0
- {coocan-0.5.6 → coocan-0.5.6.1}/setup.cfg +0 -0
@@ -1,8 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: coocan
|
3
|
-
Version: 0.5.6
|
3
|
+
Version: 0.5.6.1
|
4
4
|
Summary: Air Async Spider Framework
|
5
|
-
Author: wauo
|
6
5
|
Author-email: wauo <markadc@126.com>
|
7
6
|
License-Expression: MIT
|
8
7
|
Project-URL: Homepage, https://github.com/markadc/coocan
|
@@ -11,8 +10,6 @@ Description-Content-Type: text/markdown
|
|
11
10
|
Requires-Dist: click>=8.0.0
|
12
11
|
Requires-Dist: httpx
|
13
12
|
Requires-Dist: loguru
|
14
|
-
Dynamic: author
|
15
|
-
Dynamic: requires-python
|
16
13
|
|
17
14
|
# 项目说明
|
18
15
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from coocan import Request, Response, MiniSpider
|
2
|
+
|
3
|
+
|
4
|
+
class UseProxySpider(MiniSpider):
|
5
|
+
start_urls = ["https://httpbin.org/ip"]
|
6
|
+
max_requests = 5
|
7
|
+
delay = 5
|
8
|
+
|
9
|
+
def start_requests(self):
|
10
|
+
proxy = "http://127.0.0.1:1082"
|
11
|
+
yield Request(self.start_urls[0], callback=self.parse, proxy=proxy)
|
12
|
+
|
13
|
+
def middleware(self, request: Request):
|
14
|
+
request.headers["Referer"] = "https://httpbin.org"
|
15
|
+
|
16
|
+
def parse(self, response: Response):
|
17
|
+
print(response.status_code, response.json())
|
18
|
+
|
19
|
+
|
20
|
+
if __name__ == '__main__':
|
21
|
+
s = UseProxySpider()
|
22
|
+
s.go()
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import time
|
2
|
+
from typing import Callable
|
3
|
+
|
4
|
+
import httpx
|
5
|
+
|
6
|
+
cli = httpx.AsyncClient()
|
7
|
+
|
8
|
+
|
9
|
+
class Request:
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
url: str, callback: Callable = None, cb_kwargs=None,
|
13
|
+
params=None, headers=None,
|
14
|
+
data=None, json=None,
|
15
|
+
proxy=None, timeout=6,
|
16
|
+
priority=None
|
17
|
+
):
|
18
|
+
self.url = url
|
19
|
+
self.callback = callback
|
20
|
+
self.cb_kwargs = cb_kwargs or {}
|
21
|
+
self.params = params
|
22
|
+
self.headers = headers or {}
|
23
|
+
self.data = data
|
24
|
+
self.json = json
|
25
|
+
self.proxy = proxy
|
26
|
+
self.timeout = timeout
|
27
|
+
self.priority = priority or time.time()
|
28
|
+
self.__client = None
|
29
|
+
|
30
|
+
@property
|
31
|
+
def client(self):
|
32
|
+
if self.proxy is None:
|
33
|
+
return cli
|
34
|
+
return httpx.AsyncClient(proxy=self.proxy)
|
35
|
+
|
36
|
+
async def send(self):
|
37
|
+
if (self.data and self.json) is None:
|
38
|
+
response = await self.client.get(self.url, params=self.params, headers=self.headers, timeout=self.timeout)
|
39
|
+
elif self.data or self.json:
|
40
|
+
response = await self.client.post(self.url, params=self.params, headers=self.headers, data=self.data, json=self.json, timeout=self.timeout)
|
41
|
+
else:
|
42
|
+
raise Exception("仅支持 GET 和 POST 请求")
|
43
|
+
return response
|
44
|
+
|
45
|
+
def __lt__(self, other):
|
46
|
+
return self.priority < other.priority
|
@@ -1,8 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: coocan
|
3
|
-
Version: 0.5.6
|
3
|
+
Version: 0.5.6.1
|
4
4
|
Summary: Air Async Spider Framework
|
5
|
-
Author: wauo
|
6
5
|
Author-email: wauo <markadc@126.com>
|
7
6
|
License-Expression: MIT
|
8
7
|
Project-URL: Homepage, https://github.com/markadc/coocan
|
@@ -11,8 +10,6 @@ Description-Content-Type: text/markdown
|
|
11
10
|
Requires-Dist: click>=8.0.0
|
12
11
|
Requires-Dist: httpx
|
13
12
|
Requires-Dist: loguru
|
14
|
-
Dynamic: author
|
15
|
-
Dynamic: requires-python
|
16
13
|
|
17
14
|
# 项目说明
|
18
15
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
README.md
|
2
2
|
pyproject.toml
|
3
|
-
setup.py
|
4
3
|
coocan/__init__.py
|
5
4
|
coocan/gen.py
|
6
5
|
coocan/push_project.py
|
@@ -13,6 +12,7 @@ coocan.egg-info/top_level.txt
|
|
13
12
|
coocan/_examples/crawl_csdn_detail.py
|
14
13
|
coocan/_examples/crawl_csdn_list.py
|
15
14
|
coocan/_examples/recv_item.py
|
15
|
+
coocan/_examples/use_proxy.py
|
16
16
|
coocan/_examples/view_local_ip.py
|
17
17
|
coocan/cmd/__init__.py
|
18
18
|
coocan/cmd/cli.py
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import time
|
2
|
-
from typing import Callable
|
3
|
-
|
4
|
-
import httpx
|
5
|
-
|
6
|
-
cli = httpx.AsyncClient()
|
7
|
-
|
8
|
-
|
9
|
-
class Request:
|
10
|
-
def __init__(self, url: str, callback: Callable = None, params=None, headers=None, data=None, json=None, timeout=None, cb_kwargs=None, priority=None):
|
11
|
-
self.url = url
|
12
|
-
self.callback = callback
|
13
|
-
self.params = params
|
14
|
-
self.headers = headers or {}
|
15
|
-
self.data = data
|
16
|
-
self.json = json
|
17
|
-
self.timeout = timeout
|
18
|
-
self.cb_kwargs = cb_kwargs or {}
|
19
|
-
self.priority = priority or time.time()
|
20
|
-
|
21
|
-
async def send(self):
|
22
|
-
if (self.data and self.json) is None:
|
23
|
-
response = await cli.get(self.url, params=self.params, headers=self.headers, timeout=self.timeout)
|
24
|
-
elif self.data or self.json:
|
25
|
-
response = await cli.post(self.url, params=self.params, headers=self.headers, data=self.data, json=self.json, timeout=self.timeout)
|
26
|
-
else:
|
27
|
-
raise Exception("仅支持 GET 和 POST 请求")
|
28
|
-
return response
|
29
|
-
|
30
|
-
def __lt__(self, other):
|
31
|
-
return self.priority < other.priority
|
coocan-0.5.6/setup.py
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
from setuptools import setup, find_packages
|
2
|
-
|
3
|
-
with open("README.md", "r", encoding="utf-8") as f:
|
4
|
-
long_description = f.read()
|
5
|
-
|
6
|
-
setup(
|
7
|
-
name="coocan",
|
8
|
-
version="0.5.6",
|
9
|
-
author="wauo",
|
10
|
-
author_email="markadc@126.com",
|
11
|
-
description="Air Spider Framework",
|
12
|
-
packages=find_packages(),
|
13
|
-
python_requires=">=3.10",
|
14
|
-
|
15
|
-
long_description=long_description,
|
16
|
-
long_description_content_type="text/markdown",
|
17
|
-
|
18
|
-
install_requires=[
|
19
|
-
'click>=8.0.0', 'httpx', 'loguru'
|
20
|
-
],
|
21
|
-
entry_points={
|
22
|
-
'console_scripts': [
|
23
|
-
'coocan=coocan.cmd.cli:main',
|
24
|
-
],
|
25
|
-
},
|
26
|
-
package_data={
|
27
|
-
'coocan': ['templates/*'],
|
28
|
-
},
|
29
|
-
include_package_data=True
|
30
|
-
)
|
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
|