pandas 为什么我在尝试使用snscraper时会出现此错误?

k10s72fa  于 2023-04-28  发布在  其他
关注(0)|答案(1)|浏览(241)

下面的代码:

import time
import pandas as pd

# pip install snscrape
!pip install snscrape

# Pull Twitter data using SNScrape
import snscrape.modules.twitter as sntwitter

scraper = sntwitter.TwitterSearchScraper("#python")

for tweet in scraper.get_items():
  break

tweet

继续抛出此错误:
“错误:snscrape.base:检索https://api.twitter.com/2/search/adaptive.json?include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&include_ext_is_blue_verified=1&include_ext_verified_type=1&skip_status=1&cards_platform=Web-12&include_cards=1&include_ext_alt_text=true&include_ext_limited_action_results=false&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_ext_collab_control=true&include_ext_views=true&include_entities=true&include_user_entities=true&include_ext_media_color=true&include_ext_media_availability=true&include_ext_sensitive_media_warning=true&include_ext_trusted_friends_metadata=true&send_error_codes=true&simple_quoted_tweet=true&q=%23python&tweet_search_mode=live&count=20&query_source=spelling_expansion_revert_click&pc=1&spelling_corrections=1&include_ext_edit_control=true&ext=mediaStats%2ChighlightedLabel%2ChasNftAvatar%2CvoiceInfo%2Cenrichments%2CsuperFollowMetadata%2CunmentionInfo%2CeditControl%2Ccollab_control%2Cvibe时出错:阻塞(403)关键:snscraping.base:4个请求对https://api.twitter.com/2/search/adaptive.json?include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&include_ext_is_blue_verified=1&include_ext_verified_type=1&skip_status=1&cards_platform=Web-12&include_cards=1&include_ext_alt_text=true&include_ext_limited_action_results=false&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_ext_collab_control=true&include_ext_views=true&include_entities=true&include_user_entities=true&include_ext_media_color=true&include_ext_media_availability=true&include_ext_sensitive_media_warning=true&include_ext_trusted_friends_metadata=true&send_error_codes=true&simple_quoted_tweet=true&q=%23python&tweet_search_mode=live&count=20&query_source=spelling_expansion_revert_click&pc=1&spelling_corrections=1&include_ext_edit_control=true&ext=mediaStats%2ChighlightedLabel%2ChasNftAvatar%2CvoiceInfo%2Cenrichments%2CsuperFollowMetadata%2CunmentionInfo%2CeditControl%2Ccollab_control%2Cvibe失败,放弃。关键:snscraping.base:错误:blocked(403),blocked(403),blocked(403),blocked(403),blocked(403)------------------------------------------------------------------------------- ScraperException Traceback(most recent call last)in〈cell line:12〉()10 scraper = sntwitter.TwitterSearchScraper(“#python”)11 ---〉12对于scraper中的推文。get_items():13 break 14 4 frames /usr/local/lib/python3.9/dist-packages/snscrape/base.pyin _request(self,method,url,params,data,headers,timeout,responseOkCallback,allowRedirects,proxies)245 _logger.fatal(msg)246 _logger.fatal(f'Errors:{",“.join(errors)}')--〉247 raise ScraperException(msg)248 raise RuntimeError('Reached unreachable code')249 ScraperException:4次请求https://api.twitter.com/2/search/adaptive.json?include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&include_ext_is_blue_verified=1&include_ext_verified_type=1&skip_status=1&cards_platform=Web-12&include_cards=1&include_ext_alt_text=true&include_ext_limited_action_results=false&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_ext_collab_control=true&include_ext_views=true&include_entities=true&include_user_entities=true&include_ext_media_color=true&include_ext_media_availability=true&include_ext_sensitive_media_warning=true&include_ext_trusted_friends_metadata=true&send_error_codes=true&simple_quoted_tweet=true&q=%23python&tweet_search_mode=live&count=20&query_source=spelling_expansion_revert_click&pc=1&spelling_corrections=1&include_ext_edit_control=true&ext=mediaStats%2ChighlightedLabel%2ChasNftAvatar%2CvoiceInfo%2Cenrichments%2CsuperFollowMetadata%2CunmentionInfo%2CeditControl%2Ccollab_control%2Cvibe失败,放弃。
我不知道为什么我得到这个错误.起初,我以为我打了一个速率限制或什么,我的IP被封锁,所以我尝试了几个不同的网络与不同的设备与不同的谷歌帐户,每次我得到相同的错误.它可能是与Python或snscraper版本的东西?

hlswsv35

hlswsv351#

这是因为snscrape在没有任何认证的情况下搜索Twitter数据,即,它在不使用您的电子邮件、密码或认证密钥的情况下搜索Twitter数据。但是现在,Twitter已经限制了在不登录Twitter网站的情况下搜索数据,即,如果您在Twitter网站上注销您的Twitter帐户,则在那里将不具有搜索功能。因此,snscrape目前无法从Twitter网站提取tweets数据。
Twitter的功能将来可能会改变,或者API可能会改进,但到目前为止,scscscrape还不起作用。
有关详细信息,请访问check here

相关问题