7 ms·
A Python-based CLI for working with Hacker News.
- nicksergeant 15y agoI started this to specifically dump my saved stories to an XML feed, which I hook up to http://ifttt.com http://ifttt.com and auto-import into Pinboard. Working great, so far. I know there are a bunch of HN CLIs out there, but none handle saved stories (the only thing this supports, right now).
- pyre 15y agoMine only does saved stories. Though it's in Perl, not Python. It was whipped up in response to a complaint several months ago. It just never had a Show HN. Http://github.com/bsandrow/hn-profile/
- draegtun 15y agoShame you didn't do a Show HN because it looks interesting/promising so thanks for pointing me to it. In return I can give you a clickable link :) http://github.com/bsandrow/hn-profile/ http://github.com/bsandrow/hn-profile/
- ez77 15y agoin response to a complaint What kind of complaint?
- pyre 15y agoSomeone was complaining in the comments that there was no easy way to get the full list of saved stories back out of HN. I whipped up this script to do that in response. It had been an idea I was batting around in the past, but the comment provided the motivation to create it. edit: Looked up the thread, and turns out it was an inquiry, and not a complaint. http://news.ycombinator.com/item?id=2479416 http://news.ycombinator.com/item?id=2479416
- ez77 15y agoItem #N I'm learning on HN today: .netrc! I read that I need a "machine remote_hostname token pair". What should I use for remote_hostname in this case? Thanks!
- ez77 15y agoSelf-answer, for anyone interested. It's in the source code [1]: die "Error: No matches for news.ycombinator.com in ~/.netrc." [1] https://github.com/bsandrow/hn-profile/blob/master/hn-profile https://github.com/bsandrow/hn-profile/blob/master/hn-profil...
- dmn001 15y agoLast week I had also written the same thing in Perl to login and handle saved stories, and then add them to a folder in Instapaper.
- narag 15y agoThank you very much, I've been wanting to do that for a long time.
- nicksergeant 15y agoIf anyone has any ideas as to how best to handle cookie caching, I'm all ears.
- mp3jeep01 15y agoYou might want to take a look into using something like twill (instead of requests) and BeautifulSoup instead of pyquery -- twill in particular will allow more control over cookies, etc.,
- pyre 15y agoI prefer lxml to BeautifulSoup.
- schrijver 15y agoI can’t find the link now, but I remember something about BeautifulSoup being deprecated—it didn’t support HTML5 last time I checked. LXML is great. http://code.google.com/p/html5lib/ http://code.google.com/p/html5lib/ is also a nice parser for HTML5 documents. Edit: pyquery wraps the aforementioned LXML. Seems like a good fit for jquery style selection…
- pyre 15y agoI tried PyQuery ~1 year ago, and immediately found issues with it (IIRC it was having trouble selecting an element that had two classes, when the selector was only specifying one of those classes). I may have to revisit that if people are recommending it with positive reviews.
- nicksergeant 15y agoGive it a shot again. I've used it with several projects over the last 6 months and have had no issues. One of the projects also involved some fairly heinous malformed HTML, and PyQuery performed well.
- 15y ago
- nicksergeant 15y agoThe next piece of this I'll be building out is a method for retrieving replies to your comments (I want an email when that happens).
- pault 15y agoYou can also use http://hnnotify.com http://hnnotify.com for this. Works great.
- nicksergeant 15y agoAh, very cool - thanks!
- vrode 15y agoThis is an enormous undertaking.
- ez77 15y agoRetrieve all saved items [...] This, by itself, is a wish come true for this programmer wannabe. Thank you wholeheartedly.
- RyanMcGreal 15y agoSee also: https://github.com/scottjacksonx/hnsh https://github.com/scottjacksonx/hnsh
- nicksergeant 15y agoSaw that but it hasn't been updated in over a year. Also didn't look like there was a quick way to export saved stories as XML.