Skip to content

Instantly share code, notes, and snippets.

@Chris2048
Created July 16, 2013 22:18
Show Gist options
  • Save Chris2048/6015687 to your computer and use it in GitHub Desktop.
Save Chris2048/6015687 to your computer and use it in GitHub Desktop.
getHN
#!/usr/bin/python2.7
import requests
def getItems(from_date, to_date):
api_root = 'http://api.thriftdb.com/api.hnsearch.com/items/_search'
url = api_root + '?filter[fields][create_ts]=[{}+TO+{}]'.format(from_date, to_date)
payload = {
'limit': 100,
'sortby': 'create_ts desc',
'filter[fields][title]': 'Show\ HN\*',
'filter[fields][type]': 'submission',
}
r = requests.get(url, params=payload)
print r.url
print r.json()['hits']
for i in r.json()['results']:
print i['item']['title']
getItems('2013-06-10T00:00:00Z', '2013-06-20T00:00:00Z')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment