A simple script to compare badges for two Telehack users. Uses the /u/username.json
API, rather than the older HTML user page /u/username
URL.
For local (system-managed) Python installations: run pip3 install requests
prior to running the script per "Usage."
cd /path/to/this/local/repo
python3 -m venv venv
source venv/bin/activate
This will create a new Python virtual environment (venv) and activate it, which should change your shell prompt as a reminder.
Next,
pip3 install requests
The last line will install the requests
module, along with its dependencies, which are:
certifi==2025.7.14
charset-normalizer==3.4.2
idna==3.10
requests==2.32.4
urllib3==2.5.0
You can verify successful installation if you wish by running pip3 freeze
.
Now, deactivate the virtual environment:
deactivate
Then, modify th_badge_cmp.py
, replacing the existing shebang to reflect the virtual environment we just created:
#!/home/user/myproject/venv/bin/python
Finally, save the file. Oh, the things we Mac users have to deal with! Seriously though, a virtual environment is the best way to do this if you installed Python3 with Homebrew.
$ ./th_badge_cmp.py <user1> <user2>
Pull requests are welcome but if you created a virtual Python3 environment using the instructions above, kindly restore the original shebang until I can work out a more universal solution:
#!/usr/bin/env python3