Skip to content

illogicalextend/HackerNews-Streaming

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Hacker News recently released an official API. Unfortunately, it cannot be used to get the newest posts submitted. This script provides a faux streaming-api like method to indefinitely yield new hacker news submissions.

Can be useful if you want to create cusotm alerts (like email notifications or gtk notifications) with a simple script.

pip install lxml ujson requests

Usage

from hn import HNStream

h = HNStream()

for item in h.submission_stream():
    if 'python' in item['title'].lower():
        # trigger a custom alert you've written
        send_email(subject="Python post!", body="<a href='{}'>Link!</a>".format(item['url']))

Or if you want to listen for comments

for comment in h.comment_stream():
    if comment['by'] == 'tptacek':
        print (comment['text'])

About

Helper method for getting new hacker news submissions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%