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.3.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.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for newsheadlines-0.0.3.tar.gz
Algorithm Hash digest
SHA256 53698236919a936748fcddbd4148b17bc0950aae56349e3c94085c2744d28ede
MD5 ee218b7e6de65bc295d1e8db751030fe
BLAKE2b-256 645811141d64c71b189dae9dbd6ebe4f7a8358da1925e4c1bfbdf0b612557c5e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: newsheadlines-0.0.3-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.14

File hashes

Hashes for newsheadlines-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b120e1d904c004c1c986d516564469d6269849cfade108cba294ae65b1e05d7d
MD5 5396db12cf18bf2591f6b32a467c68be
BLAKE2b-256 049c86cb494eee0c98a6fa42cb80983c2e22ef86b768520d53fc621f4a16dc9d

See more details on using hashes here.

Provenance

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