如何获得超过一周的推文(使用 tweepy 或其他 python 库) [英] How can I get tweets older than a week (using tweepy or other python libraries)

查看:79
本文介绍了如何获得超过一周的推文(使用 tweepy 或其他 python 库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力解决这个问题,但这真的很令人沮丧.我正在尝试使用 Tweepy 获取带有特定主题标签(大量推文)的推文.但这不会超过一周.我需要回到至少两年的时间里几个月.这甚至可能吗,如果有的话怎么办?

I have been trying to figure this out but this is a really frustrating. I'm trying to get tweets with a certain hashtag (a great amount of tweets) using Tweepy. But this doesn't go back more than one week. I need to go back at least two years for a period of a couple of months. Is this even possible, if so how?

只是为了检查这里是我的代码

Just for the check here is my code

import tweepy
import csv

consumer_key = '####'
consumer_secret = '####'
access_token = '####'
access_token_secret = '####'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

# Open/Create a file to append data
csvFile = open('tweets.csv', 'a')
#Use csv Writer
csvWriter = csv.writer(csvFile)


for tweet in tweepy.Cursor(api.search,q="#ps4",count=100,\
                           lang="en",\
                           since_id=2014-06-12).items():
    print tweet.created_at, tweet.text
    csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])

推荐答案

你已经注意到 Twitter API 有一些限制,我已经实现了一个代码,它使用与在浏览器上运行的 Twitter 相同的策略来执行此操作.看一下,可以得到最老的推文:https://github.com/Jefferson-Henrique/GetOldTweets-python

As you have noticed Twitter API has some limitations, I have implemented a code that do this using the same strategy as Twitter running over a browser. Take a look, you can get the oldest tweets: https://github.com/Jefferson-Henrique/GetOldTweets-python

这篇关于如何获得超过一周的推文(使用 tweepy 或其他 python 库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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