Show HN: Archivy-HN – automatically save and download your upvoted HN posts
github.com
github.com
import requests
from bs4 import BeautifulSoup
with requests.Session() as session:
page = 1
while True:
resp = session.get(
f"https://news.ycombinator.com/upvoted?id=ashish01&p={page}",
cookies={"user": "get this from your browser"},
)
tree = BeautifulSoup(resp.text)
links = [x["href"] for x in tree.select(".subtext .age a")]
if len(links) == 0:
break
for i, link in enumerate(links):
print(page, i, link.split("=")[1])
page = page + 1Do you think it would be worthwhile to be able to save upvoted / favorited comments also? I also have to think about what context (ie parent / child comments) it would be useful to gather.
HN has a search box, but afaik there's no way to filter by user, or to restrict the search to my upvoted comments, etc.
Downloading would be a good second-best option, because at least it would allow me to "grep" through the archives.
The software this script is built around [0] comes with a developing [1] search functionality.
The idea is that using these plugins and the main software one can group / save / search their digital identity - and that's exactly what saving comments would work towards.
[0]: https://archivy.github.io [1]: https://github.com/archivy/archivy/pulls/159
(I use them a lot: https://news.ycombinator.com/favorites?id=akkartik&comments=...)
It could probably be done with a simple script and you would end up with a folder full of JSON files. Your ISP might hate you, though.
https://github.com/jaredsohn/hnuserdownload
There was also a website which is not working. Going to turn that off now.