python - Tweepy 仅返回 76 条推文

标签 python twitter web-scraping tweepy

我正在尝试从 Twitter 收集电影评论。然而,我只收到 76 条推文。我试图排除 tweeterror 但这没有帮助。这是我的代码:

import tweepy
import time
import cPickle as pickle
auth = tweepy.OAuthHandler(**hidden**)

auth.set_access_token(**hidden**)

api = tweepy.API(auth)


def limit_handled(cursor):
    while True:
        try:
            yield cursor.next()
            "I am awake..."
        except tweepy.error:
            print "going to sleep..."
            time.sleep(15 * 60)
        except StopIteration:
            break

query = '#moviereview -filter:links'
max_tweets = 1000000

searched_tweets = [status.text for status in limit_handled(tweepy.Cursor(api.search, q=query).items(max_tweets))]
with open("twitter_reviews.pkl","wb") as f:
    pickle.dump(searched_tweets,f,-1)

print len(searched_tweets)

最佳答案

尝试修改您的查询参数,根据您的代码,这不是过滤掉进一步结果的原因。

查询:

'#moviereview -filter:links' 

提供 78 个结果(并且还在增加)

查询:

'#moviereview' 

提供 1713 个结果(并且还在增加)

查询:

'#moviereview Filter:links'

提供 4534 个结果(并且还在增加)

正如 @Ethan 提到的 + Twitters API 文档 ( https://dev.twitter.com/rest/public/search )

The Twitter Search API searches against a sampling of recent Tweets published in the past 7 days.

关于python - Tweepy 仅返回 76 条推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37399639/

相关文章:

python - Tesseract 无法识别验证码文本

python - 从 virtualenv 启动 Sublime Text

python - LDA主题建模输入数据

javascript - 通过 HTTPS 获取推文

python - Scrapy:连接被拒绝

python - “NoneType”对象在 BeautifulSoup 中没有属性 'text'

html - 使用 Twitter 的新小部件时如何禁用消息 “Are you sure you want to send a form again”?

excel - VBA - 网页抓取无法获取 HTMLElement insideText

ruby - 在 ruby​​ 中更改 IP 地址

python - 对不平衡数据集进行重新采样的数据框