3 ms·
I wrote a stupid simple wrapper and pushed it to PyPI. My excuse is that I needed to learn how to use setuptools today. pip install hackernews-python Usa
by shill 12y ago
I wrote a stupid simple wrapper and pushed it to PyPI. My excuse is that I needed to learn how to use setuptools today.
pip install hackernews-python
Usage:
>>> from hackernews import HackerNews
>>> hn = HackerNews()
>>> hn.top_stories()
[8422599, 8422087, 8422928, 8422581, 8423825...
>>> hn.user('pg')
{'delay': 2, 'id': 'pg', 'submitted': [7494555, 7494520, 749411...
>>> hn.item(7494555)['title'])
Hacker News API
>>> hn.max_item()
8424314
>>> hn.updates()
{'items': [8423690, 8424315, 8424299...], 'profiles': ['exampleuser',...]}
https://github.com/abrinsmead/hackernews-python https://github.com/abrinsmead/hackernews-python
- BaryonBundle 12y agoCan't get it to work, e.g., for `hn.top_stories()` I get: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "hackernews.py", line 23, in top_stories return r.json() TypeError: 'list' object is not callable Tried in both python 2.7.3 and python 3.2.3 EDIT: You need a relatively new version of requests for this to work. The version packaged with Debian Wheezy is too old. Use pip.
- shill 12y agoThanks for the feedback! Prior to version 1.0.0 response.json() was a property, and was not callable. That's probably what caused your error. I'll add a minimum version to requirements.txt for the folks that install this package manually.