当我增加推文数量时,snscrape 不起作用

问题描述 投票:0回答:0

当我尝试使用 snscrape 抓取 100,000 条推文时出现以下错误:

WARNING:snscrape.modules.twitter:Tweet 1551723728450437121 contains an app icon medium key '4_1643299356542476289' on app 'iphone_app'/'1361356590', but the corresponding medium is missing; dropping

和:

WARNING:snscrape.modules.twitter:Tweet 1551723728450437121 contains an app icon medium key '4_1643299356542476289' on app 'ipad_app'/'1361356590', but the corresponding medium is missing; dropping

几分钟后,它停止了。

我在 Google Colab notebook 上尝试了以下代码,它对小样本运行良好。我是初学者,所以我对错误的解释可能很天真,但它似乎试图访问一条推文,但找不到到达它的路径(媒介)。这两个错误似乎都是相关的(iPhone 和 iPad)。但这种解释可能是完全错误的!由于我的样本相当大(100,000 条推文),我不介意跳过这两行,但我不知道这是否是一个好的解决方案,也不知道如何实现它。

这是我的代码:

!pip3 install git+https://github.com/JustAnotherArchivist/snscrape.git      #developer''s code to install program, recommended on snscrape documentation
import snscrape.modules.twitter as sntwitter
tweets_df = []
for i,tweet in enumerate(sntwitter.TwitterSearchScraper('John Travolta since: 2022-07-01 until:2022-10-01').get_items()):  
    if i>100000: 
        break
    tweets_df.append([tweet.date, tweet.id, tweet.content, tweet.user.username])
tweets_df = pd.DataFrame(tweets_df, columns=['Datetime', 'Tweet Id', 'Text', 'Username'])

在这些之后,我尝试查看 df 的头部,但是当我写

tweets_df.head()
时没有生成输出。

您的帮助将不胜感激。请尽量用最简单的语言解释。

tweets
© www.soinside.com 2019 - 2024. All rights reserved.