Python API for Hacker News
github.com
github.com
I think the future is Python 3, and new implementations in Python 2 syntax are simply unneccessary. I would suggest the usage of Python-3-style syntax, which is also valid in Python 2.7 (which isn't hard).
Please explain this further.
> usage of Python-3-style syntax, which is also valid in Python 2.7
Will do this
- You should certainly use Requests http://docs.python-requests.org/en/latest/
- The Story class seems somewhat redundant. You could possibly use collections.namedtuple as a container for properties or simply a dictionary. The print_story method could just be the __str__ special method.
- JSON output would be useful.
> 21 points by johns 15 minutes ago | discuss
or
> 152 points by ar7hur 3 hours ago | 58 comments
If the rgex matches (case 2), then I cast it to an int. Otherwise (case 1, 0 comments).
<td class=\"title\"><a href=\"(.?)\"(.?)>(.?)</a>(.?)</td>
http://stackoverflow.com/questions/1732348/regex-match-open-...
Building a regex to extract relevant data from simple, fixed-form page data, bypassing tags irrelevant to the problem at hand is not.
I haven't look at their parsing code, so I have no idea if it is any better than using a regex, but if the regex assumes too much, simply reordering the attributes in a tag (or something similar) could break a regex-based solution.