Commit 409c1816 authored by Rémy Decoupes's avatar Rémy Decoupes
Browse files

add twitter accound to follow

parent 74eb4614
......@@ -2,8 +2,10 @@
params/credentials.py
#### Log ####
log/collectweets.log
#### libreoffice back up ####
.~lock.*
#### Virtual Env ####
venv/
#### IDE ####
__pycache__/
__pycache__*
.idea/
\ No newline at end of file
......@@ -4,7 +4,7 @@ This project collects tweets based on a list of keywords or/and twitter accounts
Keywords and Twitter accounts lists have been defined by H2020 MOOD partners :
* [keyword](params/keywordsFilter.csv)
* [twitter account](params/accountsFollowed.csv)
* [twitter account](params/accountsFollowed.csv). For MOOD partners, the selection of accounts to follow can be found in [Alfresco](https://collaboratif.cirad.fr/share/page/site/MOODProposal/document-details?nodeRef=workspace://SpacesStore/de5d3d86-356e-4383-9078-cf4b9606c76a)
**To be compliant with Twitter's [Terms of Service](https://developer.twitter.com/en/developer-terms/agreement-and-policy)** this repository doesn't contains any tweet nor Twitter credentials.
Users who wants to use this project have to create a [Twitter developer account](https://developer.twitter.com/en)
......
......@@ -45,7 +45,8 @@ def logsetup():
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)
# Only display on screen INFO
stream_handler.setLevel(logging.INFO)
logger.addHandler(stream_handler)
return logger
......@@ -53,25 +54,27 @@ if __name__ == '__main__':
print("Collect tweets : start")
# initialize a logger :
logger = logsetup()
# try import credentials of MOODTwitter account
try:
from params import credentials
except ImportError:
msg = 'it seems there is no file named :"credentials.py"'
exitscript(logger, msg)
# Access and authorize on MOOD twitter Account
try:
auth = tweepy.OAuthHandler(credentials.consumer_key, credentials.consumer_secret)
auth.set_access_token(credentials.access_token, credentials.access_token_secret)
api = tweepy.API(auth)
# Get the User object for twitter...
user = api.get_user('twitter')
print(user.screen_name)
accountused = api.me()
logger.info("Log with: "+accountused.name)
except tweepy.TweepError as twe:
msg = "Wrong credentials: please check credentials.py "
msg = "Wrong credentials: please check credentials.py"
exitscript(logger, msg)
except Exception as e:
msg = "Please double check credentials.py :" + e
finally:
exitscript(logger, msg)
print("Collect tweets : end")
logger.info("Collect tweets : proceeded normally")
account,country,adding_date,description
@yleuutiset,Finland,2020-06-09,Yle Uutiset (in finnish)
@ylenews,Finland,2020-06-09,Yle news (in english)
@hsfi,Finland,2020-06-09,Helsingin Sanomat
@iltalehti_fi,Finland,2020-06-09,Iltalehti
@iltasanomat,Finland,2020-06-09,Iltasanomat
@SuomenKuvalehti,Finland,2020-06-09,Suomen kuvalehti
@MaasTul,Finland,2020-06-09,Maaseudun tulevaisuus
@KauppalehtiFi,Finland,2020-06-09,Kauppalehti
@Nordic_News,Finland,2020-06-09,Nordic News
@HelsinkiTimes,Finland,2020-06-09,Helsinki Times
@lemondefr,France,2020-06-09,Le Monde
@Le_Figaro,France,2020-06-09,Figaro
@LEXPRESS,France,2020-06-09,L'express
@Sciences_Avenir,France,2020-06-09,Sciences et avenir
@20Minutes,France,2020-06-09,20MINUTES
@lobs,France,2020-06-09,L'OBS
@lopinion_fr,France,2020-06-09,L'OPINION
@LaTribune,France,2020-06-09,LA TRIBUNE
@LesEchos,France,2020-06-09,LES ECHOS
@le_Parisien,France,2020-06-09,LE PARISIEN
@leJDD,France,2020-06-09,LE JDD
@OuestFrance,France,2020-06-09,OUEST FRANCE
@LaCroix,France,2020-06-09,LA CROIX
@libe,France,2020-06-09,LIBERATION
@MarianneleMag,France,2020-06-09,MARIANNE
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment