在一定时间范围内选择新闻文章的站点地图刮板

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"和{},这是一个ISO 8601 formatted datetime string(由 isoformat method)。在

有关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。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在java代码中实现两个侦听器时发生swing错误   Lambda是否完全取消了Java8中匿名内部类的使用?   swing OpenSuse 12.3+Java双显示   POM中的java错误。xml文件,即使在清理{users}/之后。m2/用于*上次更新文件的存储库   JavaEDT特定的方法和其他东西   java如何使用GridLayout设置组件大小?有更好的办法吗?   java在itext7中生成二维码时,如何调整点的大小?   java如何在多行上显示文本并右对齐?   java在WebSphereCluString环境中分离Log4j日志   JAVA从文件读取,返回BigInteger值   当使用rxjava2进行排列时,使用javamockito。重试()   在java fasterxml中创建Xml   使用64位整数进行模运算的64位整数的java快速乘法,无溢出   java静态变量保留以前发布的值   datastax enterprise SSTable loader流式处理无法提供java。木卫一。IOException:对等方重置连接   java匹配的通配符是严格的,但找不到元素“mvc:annotationdriven”的声明。标准包装。可抛出   java无法在浏览器上下载文件文档?