Skip to content

Instantly share code, notes, and snippets.

@RamenJunkie
Created November 21, 2022 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RamenJunkie/7669681fb879484087fa4bc9281ce344 to your computer and use it in GitHub Desktop.
Save RamenJunkie/7669681fb879484087fa4bc9281ce344 to your computer and use it in GitHub Desktop.
## Github.com/RamenJunkie
## This Script is quick and a little rough
##
## What is needed, Twitter Dev API Keys: https://developer.twitter.com/en
## An Export of Your Twitter Data from in the Settings Menu, this takes a few days to get
##
## Place the file following.js from the export in the "Data" folder, into the same folder as this script.
## Run the script.
## Output is an HTML file that can be opened in any browser containing links to every person you follow, with a search for "Mastodon"
##
## This makes it easy to see if any of the people you follow have tweeted about having a Mastodon account,
## just conrol+clock each link to open tabs. No Results means no Masto Tweets, results mean they probbaly have one,
## or they like the band Mastodon.
##
## Limitation: The API Documentation says it has a limit of 900 Calls per 15 minutes.
## So this may not work if you follow more than 900 people.
## You could probably get around this by manually breaking up the following.js file as it's just a long list of data.
##
## This script will also spit out a list of Usernames at the end that you can copy and paste to a file for record keeping if you want.
import tweepy
import json
url1 = "https://twitter.com/search?q=mastodon%20(from%3A"
url2 = ")&src=typed_query&f=top"
# Twitter credentials for Dev Account
# Sign up here: https://developer.twitter.com/en
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
twitter_url = "https://twitter.com/i/flow/login"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
with open("following.js") as following:
users_to_check = following.read()
users_to_check = users_to_check[29:]
users_to_check = json.loads (users_to_check)
user_names = []
for each in users_to_check:
try:
user = api.get_user(user_id = each["following"]["accountId"])
except:
pass
else:
user_names.append(user._json['screen_name'])
with open("search_links.html", mode = "a") as output:
output.write(f"<a href='{url1}{user._json['screen_name']}{url2}'>{user._json['screen_name']}</a><br>")
print(user_names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment