Skip to main content

About

This module provides the SitemapRange class and a tool to allow command-line usage sitemap_fetch.py.

The class SitemapRange is meant primarily as a generic building block for creating news aggregating applications where the datasources are spec-compliant news websites.

There are some fault-tolerance features included to deal with some inconsistencies in sitemaps.

Install

To install from pypi:

pip3 install --user sitemap-range-fetch

Usage

Fetching all news articles on cnn.com in the past 6 days, and format the result as JSON:

sitemap_fetch.py --site "https://cnn.com" --format json --daysago 6

Here is an example of using the SitemapRange class in your code:

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)

The get_articles_in_range method returns a list of dictionaries, where each dictionary has two keys: "url" and "dt" which is an ISO 8601 formatted datetime string (as returned by the isoformat method).

More details about the CLI switches:

    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

Details

This module is provided as is under MIT License.

For extensions, customizations or business inquiries you can get in touch here.

Metadata

Release files for sitemap-range-fetch 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sitemap-range-fetch 0.9.6
File Size Uploaded Provenance Actions
sitemap-range-fetch-0.9.6.tar.gz 4.8 kB Without provenance Details for sitemap-range-fetch-0.9.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sitemap-range-fetch 0.9.6
File Interpreter ABI Platform Actions
sitemap_range_fetch-0.9.6-py3-none-any.whl Python 3 none any Details for sitemap_range_fetch-0.9.6-py3-none-any.whl

Total release size: 11.4 kB

Release files / sitemap-range-fetch-0.9.6.tar.gz

Download URL sitemap-range-fetch-0.9.6.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2d9d0783cb9e8fe95dbb13c90dfbc407ced4aa8af3c329b87372b10cb7e8bd6c
BLAKE2b-256 checksum
How to use checksums
3966d7fca765702d933dd3d27a38e3dc3b59d09da315e5d73bb5911e1f8c3aee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

Release files / sitemap_range_fetch-0.9.6-py3-none-any.whl

Download URL sitemap_range_fetch-0.9.6-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15612c34cf867a0294a00a1b758900dd1a9bd9e3dce798b11fbef4fa19dfeae2
BLAKE2b-256 checksum
How to use checksums
9ab057e639360f2d4593382abb589d856784dc8d36067e679bb7ba203616dc4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

Security for sitemap-range-fetch 0.9.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page