comparison dependencies/python/url_controller.py @ 8:6541622b6127

add tweet analysis method
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Fri, 17 Sep 2021 21:10:02 +0200
parents 54e71cf6e324
children
comparison
equal deleted inserted replaced
7:1b1296559c31 8:6541622b6127
1 def create_twitter_url(twitter_user, number_of_tweets): 1 class TwitterApi:
2 """
3 Create url to fetch `max_results` of tweets from `user`
4 :param twitter_user: string, required
5 :param number_of_tweets: int, required
6 :return: string url
7 """
8 2
9 formatted_max_results = 'max_results={}'.format(number_of_tweets) 3 @staticmethod
10 formatted_user = 'query=from:{}'.format(twitter_user) 4 def create_sentiment_url(twitter_user, number_of_tweets):
11 url = "https://api.twitter.com/2/tweets/search/recent?{}&{}".format(formatted_max_results, formatted_user) 5 """
6 Create url to fetch `max_results` of tweets from `user`
7 :param twitter_user: string, required
8 :param number_of_tweets: int, required
9 :return: string url
10 """
12 11
13 return url 12 query = 'query=from:{}'.format(twitter_user)
13 url = 'https://api.twitter.com/2/tweets/search/recent?max_results={}&{}'.format(number_of_tweets, query)
14
15 return url