简体   繁体   English

如何提取@ASPCA twitter 页面的所有推文和回复?

[英]How to extract all tweets and replies of @ASPCA twitter page?

I am going to extract all tweets and replies.我将提取所有推文和回复。 I used the following code but it only extract about 3.2K tweets.我使用了以下代码,但它只提取了大约 3.2K 条推文。

import pandas as pd
import numpy as np
import tweepy 

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,wait_on_rate_limit=True)

username = 'ASPCA'

tweets = tweepy.Cursor(api.user_timeline, screen_name=username).items()
tweets_list = [[tweet.created_at, tweet.id, tweet.text, tweet.in_reply_to_status_id_str,         tweet.in_reply_to_screen_name, tweet.in_reply_to_user_id_str, tweet.user.id] for tweet in tweets]

The page has almost 34K tweets.该页面有近 34K 条推文。

I appreciate anyone to help我感谢任何人的帮助

That's correct.这是正确的。 The Twitter user_timeline API provides access to 3200 Tweets maximum. Twitter user_timeline API 最多可访问 3200 条推文。 This is the documented limit to the API.这是 API 的记录限制。

There are really two options here:这里实际上有两个选择:

  • ask the account owner to download their Twitter archive and provide you with access to the data (which I assume is not an option in this case)要求帐户所有者下载他们的 Twitter 存档并为您提供访问数据的权限(我认为在这种情况下不是一个选项)

  • use the Twitter premium full-archive search API to search for all of the Tweets sent by the user.使用 Twitter 高级全存档搜索 API 搜索用户发送的所有推文。 Since there are so many Tweets and this account is over ten years old, I would expect this to require a large number of requests, so the free sandbox tier of the API is unfortunately unlikely to work for you in this case.由于有这么多推文,而且这个帐户已有十多年历史,我预计这需要大量请求,因此不幸的是,API 的免费沙盒层级不太可能在这种情况下为您工作。

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

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