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.1.tar.gz (6.7 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.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: newsheadlines-0.0.1.tar.gz
  • Upload date:
  • Size: 6.7 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.1.tar.gz
Algorithm Hash digest
SHA256 c23d8fd2b11d3f84793db0578c22f35a0fcdbeb68248739a8185f8b885eb5d5f
MD5 e4d1dcd4e3a39a7db792c535b4982af4
BLAKE2b-256 85d56b35c56ccb8d4422501e7a144efef5d41286cc0f4f1b8b925b4f35106a51

See more details on using hashes here.

Provenance

The following attestation bundles were made for newsheadlines-0.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: newsheadlines-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0435b54d6b06f2dc32f36bbf54a6dd2e98e605f4a7abf7e082d2a9093524b3b
MD5 2afb491e368d4fc487cdbda15ef11380
BLAKE2b-256 0dafc7aa6d6cec8dfafda44ace8a9fb8975ea1b48ffc86d24cf267116352962c

See more details on using hashes here.

Provenance

The following attestation bundles were made for newsheadlines-0.0.1-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