Skip to main content

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

  1. Clone the repository:

    git clone https://github.com/pavzari/newslaunch.git
    cd newslaunch
    
  2. Create a new virtual environment:

    python -m venv venv
    source venv/bin/activate
    
  3. Install development and test dependencies:

    pip install -e '.[test]'
    
  4. 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

  1. Navigate to the newspad directory:

    cd newspad
    
  2. 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


Download files

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

Source Distribution

newslaunch-0.0.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

newslaunch-0.0.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

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

Hashes for newslaunch-0.0.0.tar.gz
Algorithm Hash digest
SHA256 faedf1e7f2e4bb89b4504ae9ab7d7ba0aed0c802d5cc86fe7065c699bf486c97
MD5 987670d6086e1b7cfef0910aefd47dff
BLAKE2b-256 f457828ac4aa3a3e807d6b040756df227b2ed9b4f24596c71363509945bc992a

See more details on using hashes here.

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

Hashes for newslaunch-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d4526fb446f6801d984ae86326e66ded59f9de5efda01ed8972ce0c0608d5c9
MD5 4dc358a774ec6049a3eb2bb9da4b63ac
BLAKE2b-256 9c7707b39502a071b0661f263c3a5a1e0b6f2d2bef0aa64e37dad05d28ac46bb

See more details on using hashes here.

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