I like to keep up to date with what’s trending on Hacker News, but not too up to date. This is a little script that makes a JSON feed with yesterday's top thirty stories, complete with links to the original item and to the comments section. I read it in NetNewsWire.
I use pipenv to install and manage Python libraries. In this case, it will install:
git clone https://github.com/samnunn/hackernews-scraper
cd hackernews-scraper
pipenv installYou need to provide the script with a URL where you intend to host your feed on the Web and an output path where you intend to save the feed on your machine. Do this by setting environment variables, which Pipenv automatically loads from a .env. You can create one with your own details like so:
echo HN_FEED_BASEURL="https://example.com/feeds" >.env # where you plan to serve the feed from, no trailing slash
echo HN_FEED_BASEPATH="/var/www/feeds/" >> .env # where on this machine you intend to save the .json file~/.pyenv/shims/pipenv run python hackernews-scraper.pyYou can trigger this however you like. If your server is a Mac, consider using a simple Keyboard Maestro macro with the do shell script action on a time of day trigger. For the brave, there's always launchd.