简单的网站爬虫,异步抓取一个网站和它能找到的所有信息,以及他们所依赖的静态内容。
simple-site-crawler的Python项目详细描述
简单的网站爬虫程序,异步爬网一个网站和所有 它可以找到的子页面,以及它们所依赖的静态内容。 您可以将它用作python项目中的库,也可以检查 提供的cli当前可以向您显示已爬网的数据 (链接、图像、css和javascript文件)为每个找到的站点创建 一个sitemap.xml文件。
主要用于播放asyncio、aiohttp和新的 async/await语法,所以:
- 它需要Python3.5或更高版本
- 目前还没有计划推出新功能;请随时提出建议 不过,如果有人真的使用 它们;-)
完全公开-我发现项目进行到一半 this 文章(和代码)几乎完全符合我的要求 由BDFL亲自撰写。哦,好吧。我还是完成了这个项目 并没有明显地复制任何东西,但它确实影响了我的一些 选择。毕竟,如果这对语言的创造者来说足够好的话 我在用,可能对我来说已经足够了。
安装
>;来自PYPI:
$ pip3 install simple-site-crawler
使用Git克隆:
$ git clone https://github.com/pawelad/simple-site-crawler $ pip3 install -r simple-site-crawler/requirements.txt $ cd simple-site-crawler/bin
用法
$ simple-site-crawler --help Usage: simple-site-crawler [OPTIONS] URL Simple website crawler that generates its sitemap and can either print it (and its static content) or export it to standard XML format. See https://github.com/pawelad/simple-site-crawler for more info. Options: -t, --max-tasks INTEGER Maximum allowed number of async tasks. -e, --export-to-xml Export sitemap to XML file. -s, --suppress Suppress printing output to stdout. --help Show this message and exit.
测试
在python上使用py.test和tox对包进行了测试 3.5和3.6(见tox.ini)。
代码覆盖率可在 Coveralls。
要自己运行测试,您需要在存储库中运行tox:
$ pip install -r requirements/dev.txt $ tox