coocan 0.4.7__tar.gz → 0.4.8__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.4.7
3
+ Version: 0.4.8
4
4
  Summary: Air Spider Framework
5
5
  Author: wauo
6
6
  Author-email: markadc@126.com
@@ -1,9 +1,10 @@
1
+ import os
1
2
  import re
2
3
  from pathlib import Path
3
4
 
4
5
  import click
5
6
 
6
- TEMPLATE_DIR = Path(__file__).parent / "templates"
7
+ TEMPLATE_DIR = Path(__file__).parent.parent / 'templates'
7
8
 
8
9
  help_info = """
9
10
  ██████╗ ██████╗ ██████╗ ██████╗ █████╗ ███╗ ██╗
@@ -26,7 +27,7 @@ def snake_to_pascal(snake_str: str):
26
27
  return pascal_str
27
28
 
28
29
 
29
- @click.group(invoke_without_command=True) # 允许无子命令调用
30
+ @click.group(invoke_without_command=True)
30
31
  @click.pass_context
31
32
  def main(ctx):
32
33
  if ctx.invoked_subcommand is None:
@@ -52,7 +53,12 @@ def new(spider):
52
53
  text = f.read()
53
54
  spider_py_text = text.replace("{SpiderClassName}", pascal)
54
55
 
55
- with open("{}.py".format(spider), 'w') as f:
56
+ py_file = "{}.py".format(spider)
57
+ if os.path.exists(py_file):
58
+ click.echo("File {} already exists".format(py_file))
59
+ return
60
+
61
+ with open(py_file, 'w') as f:
56
62
  f.write(spider_py_text)
57
63
 
58
64
  click.echo("Success")
@@ -9,7 +9,8 @@ class {SpiderClassName}(MiniSpider):
9
9
  request.headers["Referer"] = "https://github.com"
10
10
 
11
11
  def parse(self, response: Response):
12
- pass
12
+ print(response.status_code)
13
+ print(response.get_one("//title/text()"))
13
14
 
14
15
 
15
16
  if __name__ == '__main__':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coocan
3
- Version: 0.4.7
3
+ Version: 0.4.8
4
4
  Summary: Air Spider Framework
5
5
  Author: wauo
6
6
  Author-email: markadc@126.com
@@ -10,9 +10,9 @@ coocan.egg-info/requires.txt
10
10
  coocan.egg-info/top_level.txt
11
11
  coocan/cmd/__init__.py
12
12
  coocan/cmd/cli.py
13
- coocan/cmd/templates/spider.txt
14
13
  coocan/spider/__init__.py
15
14
  coocan/spider/base.py
15
+ coocan/templates/spider.txt
16
16
  coocan/url/__init__.py
17
17
  coocan/url/request.py
18
18
  coocan/url/response.py
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as f:
5
5
 
6
6
  setup(
7
7
  name="coocan",
8
- version="0.4.7",
8
+ version="0.4.8",
9
9
  author="wauo",
10
10
  author_email="markadc@126.com",
11
11
  description="Air Spider Framework",
@@ -24,7 +24,7 @@ setup(
24
24
  ],
25
25
  },
26
26
  package_data={
27
- 'coocan.cmd': ['templates/*'],
27
+ 'coocan': ['templates/*'],
28
28
  },
29
29
  include_package_data=True
30
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