Skip to main content

Monitor RSS feeds for keywords and act on matching results. A special project of the Freedom of the Press Foundation.

Project description

Track The News

trackthenews is the script that powers @FOIAfeed, a Twitter bot that monitors news outlets for reporting that incorporates public records laws like the Freedom of Information Act (FOIA), and tweets links to and excerpts from matching articles. The underlying software can track any collection of RSS feeds for any keywords.

If you want to run your own instance of trackthenews, you can download and install the package, and run its built-in configuration process. It can be installed with pip:

Python 3.6 is recommend but if you run into troubles, try it with Python 2.7.

pip3 install trackthenews

or by cloning the GitHub repository and running setup.py:

python3 setup.py install

Once it is installed, you can create a configuration by running the following command in the appropriate directory:

trackthenews --config

By default, the script will place all configuration files in a new ttnconfig folder in your current working directory, but you can also designate a directory for it to use.

python3 trackthenews --config ~/foo/bar/path

That configuration process will create the necessary files and walk you through setting up a Twitter bot for matching stories. After it is configured, you'll need to use a text editor to add the matchwords and RSS feeds to their respective files.

Once you've got everything set up, you can run the program without the --config flag to check for matching articles.

trackthenews

If you designated a custom installation directory, or if you're running it from another directory (or a cron job, for example) you will need to designate the directory in which the configuration files are installed.

trackthenews ~/foo/bar/path

Settings, such as the background color for new posts, the font, and the user-agent, are all located in config.yaml, in the designated configuration directory.

How it works

Most of the script is dedicated to the Article class.

  • Articles are created based on inputs. Currently those inputs are RSS feeds, which are stored in rssfeeds.json, but in future versions other inputs will include direct URLs, news APIs, Twitter feeds, or scraped pages.
  • A series of Article methods then scrape and isolate the contents of each article (currently that cleanup is done with a Python port of Readability, but future versions may incorporate some per-site parsing), check whether it's suitable for posting, and then prepare images for tweeting.
  • Finally, the Article tweets itself.

All articles are recorded in a sqlite database.

Advanced feature: blocklist

In some cases, you may wish to suppress articles from being posted, even though they would otherwise match. You can do so by writing a new function, check, and placing it in a file named blocklist.py in the configuration directory. check takes an Article (and so has access to its outlet, title, and url) and should return true for any article that should be skipped.

License

MIT.

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

trackthenews-0.1.8.14.tar.gz (280.4 kB view details)

Uploaded Source

Built Distribution

trackthenews-0.1.8.14-py3-none-any.whl (278.8 kB view details)

Uploaded Python 3

File details

Details for the file trackthenews-0.1.8.14.tar.gz.

File metadata

File hashes

Hashes for trackthenews-0.1.8.14.tar.gz
Algorithm Hash digest
SHA256 a0d4f8db42fdbc39c796cbb124cca473b2e40c9cd7b3c639d75b7d2d5a0850b5
MD5 b87a6e7ef1c3c2d8668fa18fb20b6d35
BLAKE2b-256 94861407cc482bde7648e47164b707d8a2c4740318b9138198105f7dadb306d5

See more details on using hashes here.

File details

Details for the file trackthenews-0.1.8.14-py3-none-any.whl.

File metadata

File hashes

Hashes for trackthenews-0.1.8.14-py3-none-any.whl
Algorithm Hash digest
SHA256 764f31cb822b577227c319fe8eb870af6ac82f8357595a4be654bfc75ee0e86b
MD5 c704f886dfdc7e38e43712c712205b51
BLAKE2b-256 c6d117e06cf985a0687411c21f09314ab5272a537609e56ea6b6492f6f2081e7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page