-
Notifications
You must be signed in to change notification settings - Fork 1
/
upvoter.py
201 lines (160 loc) · 5.11 KB
/
upvoter.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
from selenium import webdriver
import time
import os
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import zipfile
from random import randint
from selenium.webdriver.common.action_chains import ActionChains
loginFile = 'created_accounts.txt'
# usera = open('user_agents.txt', 'r')
# ua = usera.read()
# user_agents = ua.splitlines()
proxy_file = open('proxies.txt', 'r')
proxies = proxy_file.read()
proxies_list = proxies.splitlines()
use_p = open('use_proxy.txt', 'r')
is_proxy = use_p.read()
def changeproxy():
total_proxies = len(proxies_list)
select_proxy = proxies_list[randint(1, total_proxies-1)]
proxy = select_proxy.split(':')
# total_ua = len(user_agents)
# user_agent = user_agents[randint(1, total_ua-1)]
PROXY_HOST = proxy[0]
PROXY_PORT = int(proxy[1])
PROXY_USER = proxy[2] # username
PROXY_PASS = proxy[3] # password
manifest_json = """
{
"version": "1.0.0",
"manifest_version": 2,
"name": "Chrome Proxy",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
},
"minimum_chrome_version":"22.0.0"
}
"""
background_js = """
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "http",
host: "%s",
port: parseInt(%s)
},
bypassList: ["localhost"]
}
};
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
return {
authCredentials: {
username: "%s",
password: "%s"
}
};
}
chrome.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
['blocking']
);
""" % (PROXY_HOST, PROXY_PORT, PROXY_USER, PROXY_PASS)
chrome_options = webdriver.ChromeOptions()
pluginfile = 'proxy_auth_plugin.zip'
with zipfile.ZipFile(pluginfile, 'w') as zp:
zp.writestr("manifest.json", manifest_json)
zp.writestr("background.js", background_js)
if is_proxy == 'True' or is_proxy == 'true':
chrome_options.add_extension(pluginfile)
print("\nNow proxy: ", select_proxy, "\n")
chrome_options.add_argument('--disable-notifications')
chrome_options.add_argument('--mute-audio')
# chrome_options.add_argument('--user-agent=%s' % user_agent)
driver = webdriver.Chrome(executable_path='chromedriver.exe', options=chrome_options)
return driver
def upvote_post(username, postLink):
browser = changeproxy()
browser.maximize_window()
browser.get("https://www.reddit.com/login/")
sleep(1)
browser.find_element(By.ID, 'loginUsername').click()
browser.find_element(By.ID, 'loginUsername').send_keys(str(username))
sleep(1)
browser.find_element(By.ID, 'loginPassword').click()
browser.find_element(By.ID, 'loginPassword').send_keys(password)
time.sleep(2)
try:
# browser.set_page_load_timeout(10)
browser.find_element(By.CSS_SELECTOR, 'button.AnimatedForm__submitButton:nth-child(1)').click()
except TimeoutException:
pass
sleep(3)
try:
browser.get(postLink)
time.sleep(3)
except TimeoutException:
try:
browser.get(postLink)
except:
pass
pass
browser.implicitly_wait(10)
try:
yes = browser.find_elements(By.CLASS_NAME, "_2nelDm85zKKmuD94NequP0")[1]
action = ActionChains(browser)
action.click(on_element = yes)
action.perform()
except Exception as e:
browser.refresh()
try:
browser.implicitly_wait(10)
yes = browser.find_elements(By.CLASS_NAME, "_2nelDm85zKKmuD94NequP0")[1]
action = ActionChains(browser)
action.click(on_element = yes)
action.perform()
except Exception as err:
pass
sleep(2)
browser.implicitly_wait(10)
browser.find_element(By.CLASS_NAME, "voteButton").click()
print("\nUpvote Successfully!")
sleep(2)
browser.close()
f = open(loginFile, 'r')
data = f.read()
f.close()
usernames = data.splitlines()
print("\nAll Accounts", usernames)
f2 = open('settings.txt', 'r')
data2 = f2.read()
f2.close()
password = data2.splitlines()[0]
print('\nAccount password: ',password)
f3 = open('link.txt', 'r')
postLink = f3.read()
f3.close()
for link in postLink.splitlines():
if len(link) != 0:
for user in usernames:
try:
if len(user) != 0:
upvote_post(user,link)
except:
pass