The purpose of this script is to export your upvoted posts list from Hacker News into a JSON file.
But why you may ask ? First and foremost because I haven't found any working tool that were able to do this. And second because I consider this to be my data, and I want to be able to backup it.
Please note that most of this script has been written using OpenAI ChatGPT (GPT-4o) as a teammate.
This project is an excuse to see how good AI is at helping to write small tools (I always have lots of ideas but don't have time to implement them).
hn_export_upvotes relies on two dependencies :
You can either install them with your favorite package manager or install uv and launch hn_export_upvotes.py right away.
It makes use of PEP-723 that allows to add metadata :
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.8"
# dependencies = [
# "requests",
# "beautifulsoup4"
# ]
# ///When launched the first time you'll see uv downloading and installing the dependencies :
Resolved 8 packages in 651ms
[...]
Prepared 8 packages in 583ms
Installed 8 packages in 17ms
+ beautifulsoup4==4.13.4
+ certifi==2025.6.15
+ charset-normalizer==3.4.2
+ idna==3.10
+ requests==2.32.4
+ soupsieve==2.7
+ typing-extensions==4.14.1
+ urllib3==2.5.0
I got the inspiration to use uv thanks to this blog post : Fun with uv and PEP 723 (related hn post).
usage: hn_export_upvotes.py [-h] [-u USERNAME] [-p PASSWORD] [-o OUTPUT] [--overwrite] [--debug]
Export your Hacker News (https://news.ycombinator.com/) upvoted posts to JSON.
options:
-h, --help show this help message and exit
-u, --username USERNAME
Hacker News username
-p, --password PASSWORD
Hacker News password
-o, --output OUTPUT output filename (default: upvoted_posts.json)
--overwrite overwrite output file if it already exists
--debug enable debug logging
You can also set HN_USERNAME and HN_PASSWORD environment variables to avoid using --username / --password.- Alternative export format : RSS feed (XML file) (see issue #1)
- Procedure to use a systemd timer (and not
cron) to call it periodically - Script to version the output JSON file into a git repository
- Use
ntfyto have notifications when we grab new entries
Here's a non-exhaustive list, in non-specific order, of similar projects to hn_export_upvotes :