从 Reddit 子版块获取 JSON 格式的新帖子
我该如何获取 JSON 格式的 Reddit 子版块的新帖子?只需将 .json 添加到 url (http://www.reddit.com/r/SOME_SUBREDDIT/new.json) 即可返回以下内容:
{
kind: "Listing"
-
data: {
modhash: ""
children: [ ]
after: null
before: null
}
}
Children 数组不包含任何帖子。我发现 http://www.reddit.com/r/SOME_SUBREDDIT/new 实际上路由当我需要的是 new?sort=new 时,到 new?sort=rising 。
和 /new?sort=new.json 当然不会工作。
How would I go about getting the new posts of a subreddit in JSON? Just tacking on .json to the url (http://www.reddit.com/r/SOME_SUBREDDIT/new.json) returns the following:
{
kind: "Listing"
-
data: {
modhash: ""
children: [ ]
after: null
before: null
}
}
The children array doesn't contain any posts. I've come to find that http://www.reddit.com/r/SOME_SUBREDDIT/new actually routes to new?sort=rising when what I need is new?sort=new.
and /new?sort=new.json of course wont work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
.json
修饰符应放在路径组件的末尾,而不是整个 URL。您要查找的网址是:The
.json
modifier should be put at the end of the path component, not the entire URL. The URL you're looking for is:如果您有兴趣获取所有 Reddit 新帖子的实时流,Pusher 有一个非官方的实时 Reddit API。您可以在这篇博客文章 http://blog.pusher.com/ 上阅读更多相关信息Pusher-realtime-reddit-api/.
但基本上你会做一些漂亮的事情,比如。它还提供 Ruby、Python、PHP 等版本。
免责声明:我为 Pusher 工作
If you are interested in getting a realtime stream of all of the Reddit new post, Pusher has an unofficial Realtime Reddit API. You can read more about it on this blog post http://blog.pusher.com/pusher-realtime-reddit-api/.
But it basically you do nifty things like. It's also available in Ruby, Python, PHP, etc.
Disclaimer: I work for Pusher