Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
umr-tetis
MOOD
mood-tetis-tweets-collect
Commits
1dc35d7b
Commit
1dc35d7b
authored
Jun 11, 2020
by
Rémy Decoupes
Browse files
filter by keywords OR accounts
parent
d4254730
Changes
2
Hide whitespace changes
Inline
Side-by-side
collectTweets.py
View file @
1dc35d7b
...
...
@@ -101,8 +101,11 @@ if __name__ == '__main__':
# Get twitter ID of account
accounttofollowed
=
pd
.
read_csv
(
"params/accountsFollowed.csv"
)
accounttofollowedlist
=
accounttofollowed
[
'twitterID'
].
tolist
()
accounttofollowedlist
=
list
(
map
(
str
,
accounttofollowedlist
))
accounttofollowedlist
=
list
(
map
(
str
,
accounttofollowed
[
'twitterID'
].
tolist
()))
# Get hashtag to track
hashtagtracked
=
pd
.
read_csv
(
"params/keywordsFilter.csv"
)
hashtagtrackedList
=
list
(
map
(
str
,
hashtagtracked
[
'hashtags'
].
tolist
()))
# Start a Twitter stream
timestr
=
time
.
strftime
(
"%Y%m%d-%H%M%S"
)
...
...
@@ -112,7 +115,7 @@ if __name__ == '__main__':
stream
=
tweepy
.
Stream
(
auth
=
api
.
auth
,
listener
=
myStreamListener
)
try
:
logger
.
info
(
"Start streaming"
)
stream
.
filter
(
follow
=
accounttofollowedlist
)
stream
.
filter
(
follow
=
accounttofollowedlist
,
track
=
hashtagtrackedList
)
except
KeyboardInterrupt
as
e
:
logger
.
info
(
"Stream Keyboard Interrupt"
)
finally
:
...
...
params/keywordsFilter.csv
View file @
1dc35d7b
hashtags,disease,add_date
coronavirus,covid19,2020-06-11
covid-19,covid19,2020-06-11
covid19,covid19,2020-06-11
ncov,covid19,2020-06-11
2019-ncov,covid19,2020-06-11
n-cov2019,covid19,2020-06-11
ncov2019,covid19,2020-06-11
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment