From c5b0aba8cfed25ee21e5bf2e1a399d73d011b044 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 21 Nov 2021 22:02:37 -0500 Subject: [PATCH] [M] Change the folder name collect to raw_collect --- {collect => raw_collect}/twitter.py | 29 +++++++++++++++++++ .../twitter_individual.py | 2 +- {collect => raw_collect}/utils.py | 0 3 files changed, 30 insertions(+), 1 deletion(-) rename {collect => raw_collect}/twitter.py (83%) rename {collect => raw_collect}/twitter_individual.py (80%) rename {collect => raw_collect}/utils.py (100%) diff --git a/collect/twitter.py b/raw_collect/twitter.py similarity index 83% rename from collect/twitter.py rename to raw_collect/twitter.py index 30dcc46..02b899f 100644 --- a/collect/twitter.py +++ b/raw_collect/twitter.py @@ -117,6 +117,15 @@ def download_user_tweets(api: API, screen_name: str) -> None: f.write(json_stringify(postings)) + + + + :param start_point: + :param n: How many users do you want to download? + :return: + """ + + def convert_to_generic(username: str, tweet: Tweet) -> Posting: """ Convert a twitter's tweet to a generic posting @@ -130,3 +139,23 @@ def convert_to_generic(username: str, tweet: Tweet) -> Posting: popularity=tweet.favorite_count + tweet.retweet_count, repost=hasattr(tweet, 'retweeted_status'), date=tweet.created_at) + + +def get_user_followings_data(api: API, screen_name: str) -> list[str]: + """ + Get a user's followings - a list of user that a specific user follows. + + We limited the result to 5000 entries because that is the maximum entries per query that the + twitter API allows. And we think 5000 entries is an enough sample size. + + :param api: Tweepy API + :param screen_name: The user's screen name + :return: List of users that the user follows. + """ + return api.get_friends(screen_name=screen_name, count=5000) + + +if __name__ == '__main__': + conf = load_config() + api = tweepy_login(conf) + print(json.dumps(get_user_followings(api, "sauricat"))) diff --git a/collect/twitter_individual.py b/raw_collect/twitter_individual.py similarity index 80% rename from collect/twitter_individual.py rename to raw_collect/twitter_individual.py index e494575..4074af0 100644 --- a/collect/twitter_individual.py +++ b/raw_collect/twitter_individual.py @@ -6,5 +6,5 @@ if __name__ == '__main__': conf = load_config() api = tweepy_login(conf) - download_user_tweets(api, 'voxdotcom') + download_user_tweets(api, 'sauricat') diff --git a/collect/utils.py b/raw_collect/utils.py similarity index 100% rename from collect/utils.py rename to raw_collect/utils.py