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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c23d8fd2b11d3f84793db0578c22f35a0fcdbeb68248739a8185f8b885eb5d5f
|
|
| MD5 |
e4d1dcd4e3a39a7db792c535b4982af4
|
|
| BLAKE2b-256 |
85d56b35c56ccb8d4422501e7a144efef5d41286cc0f4f1b8b925b4f35106a51
|
Provenance
The following attestation bundles were made for newsheadlines-0.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on theomaillard/newsheadlines
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
newsheadlines-0.0.1.tar.gz -
Subject digest:
c23d8fd2b11d3f84793db0578c22f35a0fcdbeb68248739a8185f8b885eb5d5f - Sigstore transparency entry: 1564113338
- Sigstore integration time:
-
Permalink:
theomaillard/newsheadlines@91b5d1156e4ad47fd8b1fb2609249a4798dd9b4c -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/theomaillard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@91b5d1156e4ad47fd8b1fb2609249a4798dd9b4c -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0435b54d6b06f2dc32f36bbf54a6dd2e98e605f4a7abf7e082d2a9093524b3b
|
|
| MD5 |
2afb491e368d4fc487cdbda15ef11380
|
|
| BLAKE2b-256 |
0dafc7aa6d6cec8dfafda44ace8a9fb8975ea1b48ffc86d24cf267116352962c
|
Provenance
The following attestation bundles were made for newsheadlines-0.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on theomaillard/newsheadlines
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
newsheadlines-0.0.1-py3-none-any.whl -
Subject digest:
f0435b54d6b06f2dc32f36bbf54a6dd2e98e605f4a7abf7e082d2a9093524b3b - Sigstore transparency entry: 1564113346
- Sigstore integration time:
-
Permalink:
theomaillard/newsheadlines@91b5d1156e4ad47fd8b1fb2609249a4798dd9b4c -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/theomaillard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@91b5d1156e4ad47fd8b1fb2609249a4798dd9b4c -
Trigger Event:
push
-
Statement type: