Skip to main content

A utility for retrieving and streaming news articles for analysis and processing.

Project description

PyPI Tests

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: newslaunch-0.0.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for newslaunch-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c244e6d36099f5a30fa085f2e3e87b1ab89da28b8e731e8db1e579241d2c4595
MD5 ee1e6c249fbb812976263c6bce075e12
BLAKE2b-256 83923f149c05c9f15775a524b4f24a36e61b4f73e96b6518cf1c9abf774b6dbd

See more details on using hashes here.

File details

Details for the file newslaunch-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: newslaunch-0.0.1-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.12.4

File hashes

Hashes for newslaunch-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a05e84a1f987467219f291262eed3ce101ffe071921d1bf5c4d27f25e068b153
MD5 0c467a3cbf5567f9a9f1d5acf7211318
BLAKE2b-256 d2fbdce9fb863acd4ff6fce02e0f8a16dc7740aab631e5d366e020550bb8969c

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