Skip to content

Instantly share code, notes, and snippets.

@bsnux
Created July 28, 2015 01:04
Show Gist options
  • Save bsnux/95117a92b5f5884b1de5 to your computer and use it in GitHub Desktop.
Save bsnux/95117a92b5f5884b1de5 to your computer and use it in GitHub Desktop.
Getting recent Hacker News stories about Python and Django
https = require 'https'
url = 'https://hacker-news.firebaseio.com/v0/topstories.json'
base_item_url = 'https://hacker-news.firebaseio.com/v0/item/'
pattern = /python|django/i
https.get url, (res) ->
res.on 'data', (codes) ->
for code in JSON.parse(codes)
item_url = base_item_url + code + '.json'
https.get item_url, (res_item) ->
res_item.on 'data', (story_res) ->
story = JSON.parse(story_res)
console.log story.title + '\t' + story.url if story.title.match(pattern)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment