获取公共 Twitter 个人资料的推文 [英] Get tweets of a public twitter profile

查看:24
本文介绍了获取公共 Twitter 个人资料的推文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Twitter 上有一个用户名列表,其个人资料是公开的.我希望获得他们从形成个人资料之日起发布的所有推文".我在 GitHub.
根据 Twitter API 文档,只返回最近的 20 条推文.无论如何我可以执行我的任务吗?

I have a list of usernames on Twitter whose profiles are public. I wish to get "all the tweets" they have posted from the day they formed their profile. I checked Twitter4J examples on GitHub.
According to the Twitter API documentation, only the 20 most recent tweets are returned. Is there anyway I could perform my task?

推荐答案

要使用 Twitter4J 获取用户的所有帖子,您必须在多个页面上提出请求.

To use Twitter4J to get all posts from a user you'll have to make your request over multiple pages..

以下基于示例的代码 在 GitHub 上

Twitter unauthenticatedTwitter = new TwitterFactory().getInstance();
//First param of Paging() is the page number, second is the number per page (this is capped around 200 I think.
Paging paging = new Paging(1, 100);
List<Status> statuses = unauthenticatedTwitter.getUserTimeline("google",paging);

循环并继续抓取新页面,直到没有新帖子为止.

Just loop and keep grabbing new pages until there are no new posts should work.

这篇关于获取公共 Twitter 个人资料的推文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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