Python API allowing you to automize a personalized news delivery system.
Project description
twitter-news-bot
A python API allowing users to:
- Scrape news articles from Google News.
- Extract the articles from the news sources.
- Create and post tweets(or now Xs) using
tweepy
. - Leverage PaLM to generate summaries from articles as tweets and to generate tweets.
- Pipeline and automate the scraping and tweeting procedure using a
cron
job.
Quick Start
For complete documentation and examples, please refer to the documentation.
Installation
pip install twitternewsbot
Requirements - before using the API
For more information on how to generate the following keys and tokens, please refer to the documentation.
-
To use the
tweepy
API to post tweets, you must have a Twitter developer account and create an app. You can create an app here. Don't worry, Twitter gives you 1 free app. Once you have created an app, you will need to generate the following keys and tokens:- Consumer API key
- Consumer API secret key
- Access token
- Access token secret
-
To use PaLM to generate tweets and completely automate the process, you will need to generate a PaLM API. To get this, you will need to sign up for the waitlist here. You can then generate the API key.
These keys must be stored in a .env
file in the root directory of your project. The .env
file should look like this:
API_KEY="your-key-here"
API_SECRET_KEY="your-key-here"
ACCESS_TOKEN="your-key-here"
ACCESS_TOKEN_SECRET="your-key-here"
GOOGLE_API_KEY="your-key-here"
Usage
The API is very simple to use. Here is a quick example:
from twitter_news_bot.tweeter import Tweeter
from twitter_news_bot.newsfinder import NewsFinder
from twitter_news_bot.twitternewsbot import TwitterNewsBot
# Create a NewsFinder and Tweeter Object
nf = NewsFinder()
t = Tweeter()
# Create a TwitterNewsBot object
tnb = TwitterNewsBot(nf, t, topic="AI")
# Run the TwitterNewsBOt to scrape articles, extract them, summarize them and post them as tweets
tnb.run()
Future Updates
- Add support for other summarization models such as OpenAI.
- Add region based searching for news articles on Google News.
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
File details
Details for the file twitternewsbot-2.0.3.tar.gz
.
File metadata
- Download URL: twitternewsbot-2.0.3.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d43754d1dafc1a8cc2a237ce4dc29088a9cbfb0259d1bc387297c0015acc9e15 |
|
MD5 | af62bcdeb0439b3bbd8afa834ad69abf |
|
BLAKE2b-256 | 047bf0e0a7669ff4a39e27fb327fbdb5798f69a410a95196a077627635dfd5bf |