Skip to content

Commit

Permalink
More robust TwitterGuestAPIScraper
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomguithereal committed Feb 20, 2024
1 parent a0c8728 commit da98a7a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions minet/twitter/api_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,8 @@ def __init__(self):
timeout=TWITTER_PUBLIC_API_DEFAULT_TIMEOUT, spoof_tls_ciphers=True
)

# NOTE: 1 call per second
self.rate_limiter_state = RateLimiterState(1)
# NOTE: 1 call per 2 second
self.rate_limiter_state = RateLimiterState(1, 2)

self.reset()

Expand Down Expand Up @@ -926,6 +926,7 @@ def api_call(self, url):

return data

@retrying_method()
def tweet(self, tweet_id, locale=None):
url = "https://api.twitter.com/graphql/8be30APApp7lds22UzVS7Q/TweetResultByRestId?variables=%7B%22tweetId%22%3A%22{}%22%2C%22withCommunity%22%3Afalse%2C%22includePromotedContent%22%3Afalse%2C%22withVoice%22%3Afalse%7D&features=%7B%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22c9s_tweet_anatomy_moderator_badge_enabled%22%3Atrue%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Atrue%2C%22responsive_web_twitter_article_tweet_consumption_enabled%22%3Afalse%2C%22tweet_awards_web_tipping_enabled%22%3Afalse%2C%22freedom_of_speech_not_reach_fetch_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Atrue%2C%22rweb_video_timestamps_enabled%22%3Atrue%2C%22longform_notetweets_rich_text_read_enabled%22%3Atrue%2C%22longform_notetweets_inline_media_enabled%22%3Atrue%2C%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22responsive_web_media_download_video_enabled%22%3Afalse%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D".format(
quote(tweet_id)
Expand Down

0 comments on commit da98a7a

Please sign in to comment.