检索 Twitter 帐户从特定日期到当前日期的推文
我想编写一个脚本来从 Twitter 帐户检索推文。这是我想要实现的场景:我的脚本应该能够检索从特定日期开始的用户的所有推文(用户可以将其设置为任何日期,只要它早于当前日期),直到当前日期。
示例:我想获取某个用户从 2011 年 1 月 1 日到当前日期(例如 2011 年 6 月 10 日)的所有推文
我的问题:如何实现这一目标?我不需要代码,我只需要场景的逻辑或流程。非常感谢任何建议或答案。谢谢。
注意:该脚本是用 Python 编写的,它利用 python-twitter 库与 Twitter API 进行对话。如果需要,也可以直接与 Twitter API 对话,无需库的帮助。该脚本将用作“桌面应用程序”而不是 Web 应用程序。
I want to write a script that retrieve the tweets from a twitter account. Here is the scenario that I would like to achieve: my script should be able to retrieve all tweets of a user starting from certain date (can be set by the user to any date as long as it's older than current date), until current date.
Example: I want to grab all the tweets of a user from 1st January 2011 until current date (e.g. 10th June 2011)
My question: how to achieve that? I don't need code, I just need the logic or flow of the scenario. Any suggestions or answers are much appreciated. Thank you.
NOTE: The script is written in Python which make use of the python-twitter library to talk to Twitter API. It's also possible to talk directly to the Twitter API without the help of the library if required. This script will be used as a 'desktop application' not web application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您对 3000 个状态的限制感到满意,您可以查看此方法 。继续对下一页重复此调用,直到其中一个页面的第一条推文早于您尝试映射的日期。
然后,您需要做的就是在 date >= 01/01/2011 时迭代列表,并在该点对其进行切片。
If you're happy with a limit of 3000 statuses you could look at this method. Keep repeating this call to the next page until the first tweet of one of the pages is earlier than the date you're trying to map from.
All you need to do then is iterate through the list while date >= 01/01/2011, and slice it at that point.