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

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第三方库


热门话题
ssl证书javax。网ssl。SSLHandshakeException:java。安全cert.CertificateException:没有与IP地址匹配的主题替代名称   基于组件的体系结构的java粒度   java在读取文件中的下一行和上一行时,我得到一个空指针异常   java是什么。StrutConfig。xml。strutsdia文件?   java中如何根据枚举字段对一组对象进行排序   java Firebase setPersistenceEnabled。导致大量内存使用   java奇数编译泛型类和列表错误   java类型org没有可用的源代码。石英克隆表达;您是否忘记继承所需的模块?   java如何使用map计算列表中整数列表的和,并获得一个新列表,其中每个条目对应于每个计算出的和?   java二进制搜索不会结束   java跳过Jackson中的错误JSON数据   在服务层中使用依赖项注入时引发java空指针异常。DAO类bean为空   访问者模式如何解释这两个Java程序运行时间的差异?   用Java扩展日历   java调用通用静态方法