Spaces:
Runtime error
Runtime error
some more smaller fixes
Browse files
twitterscraper/TwitterScraper.py
CHANGED
@@ -60,9 +60,13 @@ class TwitterScraper(object):
|
|
60 |
self.conf.Search = _string # this tells twint configuration to search for string
|
61 |
return self.__get_tweets__from_twint__()
|
62 |
|
63 |
-
# TODO: Possibly include more than one user
|
64 |
def scrape_by_user_and_string(self, _user: str, _string: str):
|
65 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
66 |
self.conf.Username = _user
|
67 |
self.conf.Search = _string
|
68 |
return self.__get_tweets__from_twint__()
|
@@ -86,8 +90,8 @@ class TwitterScraper(object):
|
|
86 |
return tweets_info
|
87 |
|
88 |
def __get_tweets__from_twint__(self):
|
89 |
-
|
90 |
-
|
91 |
tweet info is a dataframe with fallowing columns
|
92 |
Index(['id', 'conversation_id', 'created_at', 'date', 'timezone', 'place',
|
93 |
'tweet', 'language', 'hashtags', 'cashtags', 'user_id', 'user_id_str',
|
@@ -107,7 +111,7 @@ class TwitterScraper(object):
|
|
107 |
self.conf.Until = self.to_date
|
108 |
self.conf.Hide_output = True # Hides the output. If set to False it will print tweets in the terminal window.
|
109 |
twint.run.Search(self.conf)
|
110 |
-
tweet_and_replies_inf = twint.output.panda.Tweets_df # here we say that output
|
111 |
if tweet_and_replies_inf.empty:
|
112 |
print("No tweet containing the word \"" + self.conf.Search + "\" could be found!")
|
113 |
else:
|
|
|
60 |
self.conf.Search = _string # this tells twint configuration to search for string
|
61 |
return self.__get_tweets__from_twint__()
|
62 |
|
|
|
63 |
def scrape_by_user_and_string(self, _user: str, _string: str):
|
64 |
+
"""
|
65 |
+
This method uses twint to extract tweets based on string and username. It takes a list of users as input.
|
66 |
+
:param _user: str
|
67 |
+
:param _string: str
|
68 |
+
:return: dataframe
|
69 |
+
"""
|
70 |
self.conf.Username = _user
|
71 |
self.conf.Search = _string
|
72 |
return self.__get_tweets__from_twint__()
|
|
|
90 |
return tweets_info
|
91 |
|
92 |
def __get_tweets__from_twint__(self):
|
93 |
+
"""
|
94 |
+
__get_tweets_from_twint__
|
95 |
tweet info is a dataframe with fallowing columns
|
96 |
Index(['id', 'conversation_id', 'created_at', 'date', 'timezone', 'place',
|
97 |
'tweet', 'language', 'hashtags', 'cashtags', 'user_id', 'user_id_str',
|
|
|
111 |
self.conf.Until = self.to_date
|
112 |
self.conf.Hide_output = True # Hides the output. If set to False it will print tweets in the terminal window.
|
113 |
twint.run.Search(self.conf)
|
114 |
+
tweet_and_replies_inf = twint.output.panda.Tweets_df # here we say that output is a dataframe
|
115 |
if tweet_and_replies_inf.empty:
|
116 |
print("No tweet containing the word \"" + self.conf.Search + "\" could be found!")
|
117 |
else:
|