在一定时间范围内选择新闻文章的站点地图刮板
sitemap-range-fetch的Python项目详细描述
关于
此模块提供SitemapRange类和允许命令行使用sitemap的工具_fetch.py。在
类SitemapRange主要用于创建新闻聚合应用程序,其中包含数据源 {a1}是新闻网站。在
其中包含了一些容错功能来处理站点地图中的一些不一致性。在
安装
要从pypi安装:
pip3 install --user sitemap-range-fetch
使用
正在获取过去6天内cnn.com上的所有新闻文章,并将结果格式化为JSON:
^{pr2}$下面是在代码中使用SitemapRange类的示例:
from sitemap_range.sitemap_range import SitemapRange
from datetime import datetime, timedelta
sr = SitemapRange("https://cnn.com")
in_range = sr.get_articles_in_range(start=datetime.now()-timedelta(days=3), end=datetime.now(), opts={})
print(in_range)
get_articles_in_range
方法返回一个字典列表,其中每个字典有两个
键:"url"
和{
有关CLI交换机的更多详细信息:
usage: sitemap_fetch.py [-h] --site SITE [--format FORMAT] [--daysago DAYSAGO]
[--notz] [--advanced]
Tool for extracting articles from news websites
optional arguments:
-h, --help show this help message and exit
--site SITE the url for the website
--format FORMAT the url for the website
--daysago DAYSAGO defines the oldest date of an article that will be
selected (default: 2 days ago)
--notz strip the timezone from the dates before selection
(processing is more fault-tolerant)
--advanced use a more fault-tolerant parser
细节
此模块在MIT License下提供。在
对于扩展、自定义或业务查询,您可以get in touch here。在
- 项目
标签: