简体   繁体   English

使用 tweepy 提取推文

[英]Extracting tweets with tweepy

I have tried using tweepy to extract tweets for a specific keyword.But the count of extracted tweets using tweepy is less compared those tweets for the specific keyword as seen on twitter search.我曾尝试使用 tweepy 提取特定关键字的推文。但是,与 twitter 搜索中看到的特定关键字的推文相比,使用 tweepy 提取的推文数量较少。 Also I want to know how to effectively extract ALL the tweets for a specific keyword of interest using any twitter data extracting library (tweepy/twython).此外,我想知道如何使用任何 twitter 数据提取库(tweepy/twython)有效地提取感兴趣的特定关键字的所有推文。 I also face a problem of irrelevant tweets with same keyword coming up.Is there a way to fine tune search and perform accurate extraction so that I get all the tweets extracted for the specific keyword.我还面临一个问题,即出现相同关键字的不相关推文。有没有办法微调搜索并执行准确提取,以便我获得针对特定关键字提取的所有推文。 Im adding the code snippet as many asked for it.But I don't have a problem with the code as its running.我添加了许多要求的代码片段。但我对代码的运行没有任何问题。

tweets = api.search('Mexican Food', count=500,tweet_mode = 'extended')
data = pd.DataFrame(data=[tweet.full_text for tweet in tweets], columns 
['Tweets'])
data.head(10)
print(tweets[0].created_at)

My question is that how to get ALL the tweets with a particular keyword.For example when I run the above code ,for each time I am getting different count of tweets.Also I cross checked with doing manual search on twitter and it seems that there are much more tweets than extracted through tweepy for the particular keyword.我的问题是如何使用特定关键字获取所有推文。例如,当我运行上面的代码时,每次我收到不同数量的推文。此外,我通过在 twitter 上进行手动搜索进行了交叉检查,似乎有比通过 tweepy 为特定关键字提取的推文要多得多。 Also I want to know if there is any way to fine tune the keyword search through python so that all the relevant tweets for my keyword of interest is fetched.另外我想知道是否有任何方法可以通过 python 微调关键字搜索,以便获取我感兴趣的关键字的所有相关推文。

The thing is when you use tweepy It has some limitation.问题是当你使用 tweepy 时它有一些限制。 It won't be able to fetch older tweets.它将无法获取较旧的推文。 So I will suggest you to use https://github.com/Jefferson-Henrique/GetOldTweets-python in place of tweepy to fetch the older tweets.因此,我建议您使用https://github.com/Jefferson-Henrique/GetOldTweets-python代替 tweepy 来获取较旧的推文。

Since you refuse to help me with your question, I'll do the bare minimum with my answer:既然你拒绝帮助我解决你的问题,我会尽量回答我的问题:

You are probably not doing pagination correctly您可能没有正确进行分页

ps: Check out the stack overflow guidelines . ps:查看堆栈溢出指南 There is an important point about Helping others reproduce the problem帮助他人重现问题有一个重要的点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM