-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtweet.py
More file actions
43 lines (33 loc) · 1.48 KB
/
tweet.py
File metadata and controls
43 lines (33 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import tweepy
import time
from datetime import datetime
print "[INFO]--" + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + "--" + "tweet" + "--" + "INIT"
with open('key.txt', 'rU') as f:
token = [line.rstrip() for line in f]
consumer_key = token[0]
consumer_secret = token[1]
access_token = token[2]
access_token_secret = token[3]
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.secure = True
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
print "[CHECK]--" + "Ready: " + api.me().name
#tweet = api.update_status(status='Updating via Tweepy!')
afps = ['CUPRUM', 'HABITAT', 'MODELO']
# Faltan CAPITAL, PLANVITAL, PROVIDA
fecha = datetime.now().strftime('%Y-%m-%d')
for afp in afps:
msg = ('Estrategia afp %s fecha %s\n'
'https://github.com/collabmarket/algorithms_afp/blob/master/README.md'
)%(afp,fecha)
images = ('result/A-E_%s.png'%afp, 'result/A-E_%s_table.png'%afp)
media_ids = [api.media_upload(i).media_id_string for i in images]
tweet = api.update_status(status=msg, media_ids=media_ids)
time.sleep(20)
url = 'http://nbviewer.jupyter.org/github/collabmarket/algorithms_afp/blob/master/SystemicRisk.ipynb'
msg = ('Riesgo Sistemico fecha %s\n %s')%(fecha,url)
images = ['result/SystemicRisk.png']
media_ids = [api.media_upload(i).media_id_string for i in images]
tweet = api.update_status(status=msg, media_ids=media_ids)
print "[INFO]--" + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + "--" + "tweet" + "--" + "DONE"