-
Notifications
You must be signed in to change notification settings - Fork 8
/
codigoBuscaSorteos.py
executable file
·58 lines (42 loc) · 1.72 KB
/
codigoBuscaSorteos.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
import tweepy
import serial
import time
# Consumer keys and access tokens, used for OAuth
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
# OAuth process, using the keys and tokens
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
# Creation of the actual interface, using authentication
api = tweepy.API(auth)
# Sample method, used to update a status
#api.update_status(status='En fin... La noche es joven...')
print ("Preparando búsqueda:")
busqueda=tweepy.Cursor(api.search, q='sorteo RT',lang='es').items()
#El string presentacion me permite avisar a mis followers que inicio al bot.
presentacion='Atentos followers que inicio experimento con bot buscasorteos. Don\'t be afraid. Con fecha: '+time.strftime("%I:%M:%S")
print (presentacion)
#api.update_status(status=presentacion)
while True:
try:
tuit=busqueda.next()
print ("Texto: ")
frase= (tuit.text.encode('utf-8'))
print (frase)
if (not("b'RT" in str(frase))):
print ("Tweet original")
api.retweet(tuit.id)
api.create_friendship(tuit.author.id)
time.sleep(10)
except tweepy.TweepError:
print ("Error de Tweepy")
time.sleep(60*15)
busqueda=tweepy.Cursor(api.search, q='#Arduino',lang='es').items()
continue
except StopIteration:
busqueda=tweepy.Cursor(api.search, q='#Arduino',lang='es').items()
print ("Busqueda terminada. Descansando...")
time.sleep(60)
continue