TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to View Latest HN Story Comments?

2 pointsby galois198about 9 years ago
When I check the comments on a post, I'm quite curious to see the latest comments but have to traverse through each branch structure. Is there an easier way to do this?

2 comments

a3nabout 9 years ago
Python 2. It works in FF on linuxmint at least. Save to hnlatest.py and run it from the command line, giving the url of a comment thread. It opens a new tab in your browser, latest comments at the bottom. &quot;Tested&quot; by inspection. :)<p>It would have been cooler to make a bookmarklet in javascript, but I didn&#x27;t want to learn javascript for this.<p><pre><code> import re import sys import tempfile import urllib2 import webbrowser try: url = sys.argv[1] page = urllib2.urlopen(url) except Exception as e: print &#x27;How to run: python hnlatest.py url&#x27; sys.exit(2) items = re.findall(&#x27;&lt;a href=&quot;item[^&gt;]+&gt;&#x27;, page.read()) items = sorted(set([x.split(&#x27;=&#x27;)[2].split(&#x27;&quot;&#x27;)[0] for x in items])) items = [&#x27;https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=&#x27; + x for x in items] with tempfile.NamedTemporaryFile(delete=False, suffix=&#x27;.html&#x27;) as tfile: for i in items: tfile.write(&#x27;&lt;a href=&quot;&#x27; + i + &#x27;&quot;&gt;&#x27; + i + &#x27;&lt;&#x2F;a&gt;&#x27; + &#x27;&lt;br&#x2F;&gt;\n&#x27;) webbrowser.open_new_tab(&#x27;file:&#x2F;&#x2F;&#x27; + tfile.name)</code></pre>
benologistabout 9 years ago
CMD or CTRL+F &quot;minutes ago&quot;