diff --git a/DIRECTORY.md b/DIRECTORY.md index 13a360ab6..e2b2442fd 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -10,6 +10,11 @@ * [Newton Raphson](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/newton_raphson.py) * [Secant Method](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/secant_method.py) +## Audio Filters + * [Butterworth Filter](https://github.com/TheAlgorithms/Python/blob/master/audio_filters/butterworth_filter.py) + * [Iir Filter](https://github.com/TheAlgorithms/Python/blob/master/audio_filters/iir_filter.py) + * [Show Response](https://github.com/TheAlgorithms/Python/blob/master/audio_filters/show_response.py) + ## Backtracking * [All Combinations](https://github.com/TheAlgorithms/Python/blob/master/backtracking/all_combinations.py) * [All Permutations](https://github.com/TheAlgorithms/Python/blob/master/backtracking/all_permutations.py) @@ -60,6 +65,7 @@ * [Base64 Encoding](https://github.com/TheAlgorithms/Python/blob/master/ciphers/base64_encoding.py) * [Base85](https://github.com/TheAlgorithms/Python/blob/master/ciphers/base85.py) * [Beaufort Cipher](https://github.com/TheAlgorithms/Python/blob/master/ciphers/beaufort_cipher.py) + * [Bifid](https://github.com/TheAlgorithms/Python/blob/master/ciphers/bifid.py) * [Brute Force Caesar Cipher](https://github.com/TheAlgorithms/Python/blob/master/ciphers/brute_force_caesar_cipher.py) * [Caesar Cipher](https://github.com/TheAlgorithms/Python/blob/master/ciphers/caesar_cipher.py) * [Cryptomath Module](https://github.com/TheAlgorithms/Python/blob/master/ciphers/cryptomath_module.py) @@ -106,8 +112,8 @@ ## Conversions * [Binary To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_decimal.py) - * [Binary To Octal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_octal.py) * [Binary To Hexadecimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_hexadecimal.py) + * [Binary To Octal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_octal.py) * [Decimal To Any](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_any.py) * [Decimal To Binary](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_binary.py) * [Decimal To Binary Recursion](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_binary_recursion.py) @@ -352,6 +358,7 @@ * [Multi Heuristic Astar](https://github.com/TheAlgorithms/Python/blob/master/graphs/multi_heuristic_astar.py) * [Page Rank](https://github.com/TheAlgorithms/Python/blob/master/graphs/page_rank.py) * [Prim](https://github.com/TheAlgorithms/Python/blob/master/graphs/prim.py) + * [Random Graph Generator](https://github.com/TheAlgorithms/Python/blob/master/graphs/random_graph_generator.py) * [Scc Kosaraju](https://github.com/TheAlgorithms/Python/blob/master/graphs/scc_kosaraju.py) * [Strongly Connected Components](https://github.com/TheAlgorithms/Python/blob/master/graphs/strongly_connected_components.py) * [Tarjans Scc](https://github.com/TheAlgorithms/Python/blob/master/graphs/tarjans_scc.py) @@ -978,6 +985,7 @@ * [Fetch Jobs](https://github.com/TheAlgorithms/Python/blob/master/web_programming/fetch_jobs.py) * [Get Imdb Top 250 Movies Csv](https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_imdb_top_250_movies_csv.py) * [Get Imdbtop](https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_imdbtop.py) + * [Get User Tweets](https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_user_tweets.py) * [Giphy](https://github.com/TheAlgorithms/Python/blob/master/web_programming/giphy.py) * [Instagram Crawler](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_crawler.py) * [Instagram Pic](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_pic.py) diff --git a/requirements.txt b/requirements.txt index 4867de26f..7c2672ae2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,5 +14,6 @@ sklearn statsmodels sympy tensorflow +tweepy types-requests xgboost diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py new file mode 100644 index 000000000..0f70201dc --- /dev/null +++ b/web_programming/get_user_tweets.py @@ -0,0 +1,60 @@ +import csv + +import tweepy + +# Twitter API credentials +consumer_key = "" +consumer_secret = "" +access_key = "" +access_secret = "" + + +def get_all_tweets(screen_name: str) -> None: + + # authorize twitter, initialize tweepy + auth = tweepy.OAuthHandler(consumer_key, consumer_secret) + auth.set_access_token(access_key, access_secret) + api = tweepy.API(auth) + + # initialize a list to hold all the tweepy Tweets + alltweets = [] + + # make initial request for most recent tweets (200 is the maximum allowed count) + new_tweets = api.user_timeline(screen_name=screen_name, count=200) + + # save most recent tweets + alltweets.extend(new_tweets) + + # save the id of the oldest tweet less one + oldest = alltweets[-1].id - 1 + + # keep grabbing tweets until there are no tweets left to grab + while len(new_tweets) > 0: + print(f"getting tweets before {oldest}") + + # all subsiquent requests use the max_id param to prevent duplicates + new_tweets = api.user_timeline( + screen_name=screen_name, count=200, max_id=oldest + ) + + # save most recent tweets + alltweets.extend(new_tweets) + + # update the id of the oldest tweet less one + oldest = alltweets[-1].id - 1 + + print(f"...{len(alltweets)} tweets downloaded so far") + + # transform the tweepy tweets into a 2D array that will populate the csv + outtweets = [[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets] + + # write the csv + with open(f"new_{screen_name}_tweets.csv", "w") as f: + writer = csv.writer(f) + writer.writerow(["id", "created_at", "text"]) + writer.writerows(outtweets) + + +if __name__ == "__main__": + # pass in the username of the account you want to download + get_all_tweets("FirePing32")