TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Python API for Hacker News

53 点作者 karangoeluw超过 11 年前

7 条评论

eeadc超过 11 年前
That library is in many ways deprecated and broken: At first, it uses only old-style classes because it doesn&#x27;t inherits object explicitly. Furthermore, it uses print in a method; it would be more &quot;Pythonic&quot; to return a str object, which was formatted using str.format.<p>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&#x27;t hard).
评论 #6377911 未加载
mapleoin超过 11 年前
I tried building a REST API once for a challenge if anyone is interested: <a href="https://github.com/mapleoin/newhackers" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mapleoin&#x2F;newhackers</a>
gpsarakis超过 11 年前
Nice effort. Just a few remarks:<p>- You should certainly use Requests <a href="http://docs.python-requests.org/en/latest/" rel="nofollow">http:&#x2F;&#x2F;docs.python-requests.org&#x2F;en&#x2F;latest&#x2F;</a><p>- 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.<p>- JSON output would be useful.
评论 #6377929 未加载
评论 #6391659 未加载
thejosh超过 11 年前
Does it use <a href="https://www.hnsearch.com/api" rel="nofollow">https:&#x2F;&#x2F;www.hnsearch.com&#x2F;api</a> ?
评论 #6374498 未加载
评论 #6374487 未加载
评论 #6374875 未加载
评论 #6375044 未加载
Sharma超过 11 年前
I think screen scrapping is not allowed by HN. Few tries with these APIs might get your IP banned!
评论 #6374540 未加载
评论 #6374689 未加载
评论 #6375728 未加载
addflip超过 11 年前
I don&#x27;t get why you&#x27;re using a try except block for the num_comments variable. You shouldn&#x27;t be casting to an int if it doesn&#x27;t have the attribute.
评论 #6375094 未加载
sprizzle超过 11 年前
It&#x27;s silly to use BeautifulSoup to parse the page when you could use a simple RegEx:<p>&lt;td class=\&quot;title\&quot;&gt;&lt;a href=\&quot;(.<i>?)\&quot;(.</i>?)&gt;(.<i>?)&lt;&#x2F;a&gt;(.</i>?)&lt;&#x2F;td&gt;
评论 #6374828 未加载
评论 #6375060 未加载
评论 #6374679 未加载
评论 #6374555 未加载
评论 #6375924 未加载