merge #6331: [twitter] add 'followers' extractor

This commit is contained in:
Mike Fährmann
2025-04-19 18:29:11 +02:00
3 changed files with 27 additions and 1 deletions

View File

@@ -998,7 +998,7 @@ Consider all listed sites to potentially be NSFW.
<tr>
<td>Twitter</td>
<td>https://x.com/</td>
<td>Avatars, Backgrounds, Bookmarks, Communities, Events, Followed Users, Hashtags, individual Images, User Profile Information, Likes, Lists, List Members, Media Timelines, Quotes, Search Results, Timelines, Tweets, User Profiles</td>
<td>Avatars, Backgrounds, Bookmarks, Communities, Events, Followers, Followed Users, Hashtags, individual Images, User Profile Information, Likes, Lists, List Members, Media Timelines, Quotes, Search Results, Timelines, Tweets, User Profiles</td>
<td>Supported</td>
</tr>
<tr>

View File

@@ -798,6 +798,17 @@ class TwitterFollowingExtractor(TwitterExtractor):
return self._users_result(TwitterAPI(self).user_following(self.user))
class TwitterFollowersExtractor(TwitterExtractor):
"""Extractor for a user's followers"""
subcategory = "followers"
pattern = BASE_PATTERN + r"/(?!search)([^/?#]+)/followers(?!\w)"
example = "https://x.com/USER/followers"
def items(self):
self.login()
return self._users_result(TwitterAPI(self).user_followers(self.user))
class TwitterSearchExtractor(TwitterExtractor):
"""Extractor for Twitter search results"""
subcategory = "search"
@@ -1411,6 +1422,15 @@ class TwitterAPI():
}
return self._pagination_users(endpoint, variables)
def user_followers_verified(self, screen_name):
endpoint = "/graphql/GHg0X_FjrJoISwwLPWi1LQ/BlueVerifiedFollowers"
variables = {
"userId": self._user_id_by_screen_name(screen_name),
"count": 100,
"includePromotedContent": False,
}
return self._pagination_users(endpoint, variables)
def user_following(self, screen_name):
endpoint = "/graphql/4QHbs4wmzgtU91f-t96_Eg/Following"
variables = {

View File

@@ -271,6 +271,12 @@ __tests__ = (
"#class" : twitter.TwitterFollowingExtractor,
},
{
"#url" : "https://twitter.com/supernaturepics/followers",
"#category": ("", "twitter", "followers"),
"#class" : twitter.TwitterFollowersExtractor,
},
{
"#url" : "https://twitter.com/search?q=nature",
"#category": ("", "twitter", "search"),