如何从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一个>