A utility for retrieving and streaming news articles for analysis and processing.
Project description
Newslaunch is a Python package that provides a simple wrapper for interacting with the Guardian API and a utility for writing data to an AWS Kinesis stream. It also includes a CLI for querying the Guardian API.
Installation
You can install Newslaunch via pip or pipx:
pip install newslaunch
pipx install newslaunch
Usage
Retrieve Articles from the Guardian and publish to AWS Kinesis
The example below shows how to use the GuardianAPI class to fetch articles from the Guardian and publish them to an AWS Kinesis stream using the KinesisWriter utility.
from newslaunch import GuardianAPI
from newslaunch import KinesisWriter
# Initialize GuardianAPI with API key from environment
guardian_api = GuardianAPI()
# Initialize KinesisWriter with the stream name
kinesis_writer = KinesisWriter(stream_name="guardian_content")
# Retrieve articles
articles = guardian_api.search_articles("python programming", from_date="2023-01-01")
# Send articles to the Kinesis stream
response = kinesis_writer.send_to_stream(articles, record_per_entry=True)
Command Line Interface (CLI)
Newslaunch also provides a CLI to interact with the Guardian API. You can set your API key and search for articles using simple commands.
newslaunch set-key --guardian <API_KEY>
newslaunch guardian "search_term"
Documentation
For more detailed documentation on each component and available options, please refer to the docs directory:
Development
-
Clone the repository:
git clone https://github.com/pavzari/newslaunch.git cd newslaunch
-
Create a new virtual environment:
python -m venv venv source venv/bin/activate
-
Install development and test dependencies:
pip install -e '.[test]'
-
Use the Makefile to run the linter and tests:
make fmt make test
Example Project: newspad
The newspad directory contains an example of how to use the newslaunch package along with Terraform and additional Python code for a producer and a consumer to interact with an AWS Kinesis stream.
Setup Instructions
-
Navigate to the
newspaddirectory:cd newspad
-
Follow the setup instructions provided in the newspad/README.md to deploy the infrastructure using Terraform and run the example producer and consumer.
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 newslaunch-0.0.0.tar.gz.
File metadata
- Download URL: newslaunch-0.0.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faedf1e7f2e4bb89b4504ae9ab7d7ba0aed0c802d5cc86fe7065c699bf486c97
|
|
| MD5 |
987670d6086e1b7cfef0910aefd47dff
|
|
| BLAKE2b-256 |
f457828ac4aa3a3e807d6b040756df227b2ed9b4f24596c71363509945bc992a
|
File details
Details for the file newslaunch-0.0.0-py3-none-any.whl.
File metadata
- Download URL: newslaunch-0.0.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d4526fb446f6801d984ae86326e66ded59f9de5efda01ed8972ce0c0608d5c9
|
|
| MD5 |
4dc358a774ec6049a3eb2bb9da4b63ac
|
|
| BLAKE2b-256 |
9c7707b39502a071b0661f263c3a5a1e0b6f2d2bef0aa64e37dad05d28ac46bb
|