Skip to main content

Latest news headlines fetcher from major sources

Project description

newsheadlines

Python package to fetch the latest news headlines from major news outlets by parsing their webpages.

ℹ️ Every response is cached for 10 minutes before a new request is made.

Installation

The latest version can be installed via pip:

pip install newsheadlines

Documentation

class Headline

A dataclass representing a single news headline.

Field Type Description
title str The headline text
source str Source identifier (e.g. "bbc")
url str | None Link to the full article, if available

newsheadlines.all(source_name)

Returns a list of all Headline objects from the given source.

Parameters

  • source_name (str) - one of the supported source keys (case-insensitive)

Returns

  • list[Headline]

Example

import newsheadlines

headlines = newsheadlines.all("bbc")

for h in headlines:
    print(h.title)
    print(h.url)
    print(h.source)

newsheadlines.main(source_name)

Returns only the top/main Headline from the given source.

Parameters

  • source_name (str) - one of the supported source keys (case-insensitive)

Returns

  • Headline

Example

import newsheadlines

headline = newsheadlines.main("bbc")

print(headline.title)
print(headline.url)
print(headline.source)

Available sources

Key Source
"apnews" AP News
"bbc" BBC News
"cnn" CNN
"nyt" The New York Times
"theguardian" The Guardian

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

newsheadlines-0.0.2.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

newsheadlines-0.0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file newsheadlines-0.0.2.tar.gz.

File metadata

  • Download URL: newsheadlines-0.0.2.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for newsheadlines-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ffcccd502421666f77319a2fcabd467dc83e6eae64106e8c123c8cec76e47439
MD5 65bf8d551ad33f272fe2d305a203f690
BLAKE2b-256 92c86e7b6a43810d680d5a2488e4c9e6a6a4a0f38142f2af4fb69436f51a8e00

See more details on using hashes here.

Provenance

The following attestation bundles were made for newsheadlines-0.0.2.tar.gz:

Publisher: publish-to-pypi.yml on theomaillard/newsheadlines

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newsheadlines-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: newsheadlines-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for newsheadlines-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f955c610dbc07c2defceefc7aaeba3c16e4a64866d366c35f7288e168db71f06
MD5 c19b4944951db1b4b4f041a3a801f4ea
BLAKE2b-256 5facd03b1368c008e57b4d1d2ef130dbd988e619259a1eeba603050ed591bfdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for newsheadlines-0.0.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on theomaillard/newsheadlines

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page