-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyscript.py
More file actions
executable file
·73 lines (55 loc) · 1.83 KB
/
myscript.py
File metadata and controls
executable file
·73 lines (55 loc) · 1.83 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import datetime
import csv
import sys
#My own functions
import mydata
import storeData
from twitterActions import *
MY_SCREEN_NAME = 'victorcastro_98'
MY_PASSWORD = open("./mypassword.txt").read().strip()
MY_PYFILE = "./mydata.py"
# Set Firefox headlessly to save resources
options = Options()
options.headless = False
browser = webdriver.Firefox(options=options)
login(browser, MY_SCREEN_NAME, MY_PASSWORD)
# Script will be lauch at 15:00 by the cron daemon
#Script will work until ~03:00 AM of the following day (12 hours more or less in total)
init = datetime.datetime.now()
#twelveHours = datetime.timedelta(hours=12)
fourHours = datetime.timedelta(hours=4)
until = init + fourHours
dataFile = open('./paisajes3.csv')
dataReader = csv.reader(dataFile, delimiter='\t')
dataList = list(dataReader)
path = "/mnt/HDD 1TB/Documentos ASUS/Recursos Python/Twitter Scripts/"
# Load status information from last execution
userStack = mydata.list
#First tweet of the csv file that will be uploaded
positionData = sys.argv[1]
for i in range(0,3):
print("Uploading tweet, positionData is " + positionData)
# Load tweet
text = dataList[positionData][0]
imgPath = path + dataList[positionData][1] + ".jpg"
positionData += 1
# Upload tweet
success = False
while not success:
success = uploadTweetImg(browser, text, imgPath)
time.sleep(10)
while init < until:
user = userStack.pop()
followUser(browser,user)
time.sleep(300)
user = userStack.pop()
#Now follow user, in the future, handle another list to unfollow users simultaneously
followUser(browser,user)
time.sleep(300)
init = until
until = init + fourHours
#Save information about execution status
storeData.usersToFile(userStack, MY_PYFILE, "list")
logout(browser)
time.sleep(5)
browser.close()