如何从reddit获取随机帖子 [英] How to get random post from reddit

查看:61
本文介绍了如何从reddit获取随机帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 https://www.reddit.com/r/creepy/

当我请求 https://www.reddit.com/r/creepy.json 我可以从 subreddit 获取前 27 个帖子.在 json 响应中有这个东西after=t3_dc9whe"——我可以将它传递给下一个请求并获取下一页.

When I request https://www.reddit.com/r/creepy.json I can get the first 27 posts from the subreddit. In the json response there is this thing "after=t3_dc9whe" - I can pass it to the next request and get next page.

我想要做的是随机之后"

What I want to do is to get random "after"

有什么办法可以做到这一点吗?也许有一种模式,我可以在这个之后"中随机化字母和数字?

Is there any way to get this done? Maybe there is a pattern and I can randomize letters and numbers in this "after"?

这是我的回购应用程序的链接:https://github.com/Krystian93/CreepyJson

This is a link to my repo app: https://github.com/Krystian93/CreepyJson

该应用正在运行,但仅显示来自 subreddit 第一页的前 27 个帖子.

The app is working but shows only first 27 post from first page of the subreddit.

推荐答案

有一个 API 端点可以获取随机帖子:

There's an API endpoint to get a random post:

GET [/r/subreddit]/random

https://www.reddit.com/dev/api/#GET_random

这篇关于如何从reddit获取随机帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆