|
1 |
| -import json |
| 1 | +import os |
| 2 | +import platform |
2 | 3 | import random
|
3 |
| -import re |
4 |
| -import traceback |
5 | 4 | import time
|
| 5 | +import traceback |
6 | 6 |
|
7 |
| -import requests |
8 |
| -from bs4 import BeautifulSoup as beautifulsoup |
9 |
| - |
| 7 | +from faker import Faker |
10 | 8 | from selenium import webdriver
|
11 |
| -from selenium.webdriver.common.proxy import Proxy |
12 |
| -from selenium.webdriver.common.proxy import ProxyType |
13 |
| - |
14 |
| - |
15 |
| -def print_list(my_list): |
16 |
| - print('---------------------') |
17 |
| - for x in my_list: |
18 |
| - print(x) |
19 |
| - # print('"' + x + '"' + ',') |
20 |
| - print('---------------------') |
21 |
| - |
22 |
| - |
23 |
| -def retrieveNames(url, file_name): |
24 |
| - user_agent = { |
25 |
| - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0' |
26 |
| - } |
27 |
| - |
28 |
| - res = requests.get(url, headers=user_agent) |
29 |
| - soup = beautifulsoup(res.content, 'html5lib') |
30 |
| - |
31 |
| - with open(file_name, 'w+', encoding='utf-8') as x: |
32 |
| - for line in list(soup.find_all('h3')): |
33 |
| - line = str(line).strip('<h3>') |
34 |
| - line = str(line).strip('</h3>') |
35 |
| - |
36 |
| - line = re.sub('\d+. ', '', line) |
37 |
| - line = line.strip(':') |
38 |
| - line = line.strip(". ") |
39 |
| - x.writelines(str(line) + '\n') |
40 | 9 |
|
41 | 10 |
|
42 |
| -def fate_proxy(): |
43 |
| - resp = requests.get('https://raw.githubusercontent.com/fate0/proxylist/master/proxy.list') |
44 |
| - a = ((resp.text).split('\n')) |
45 |
| - p_list = [] |
46 |
| - for i in a: |
47 |
| - try: |
48 |
| - p_list.append(json.loads(i)) |
49 |
| - except Exception as e: |
50 |
| - continue |
51 |
| - np_list = [] |
52 |
| - |
53 |
| - countries = ["AE", |
54 |
| - "AR", |
55 |
| - "AU", |
56 |
| - "AZ", |
57 |
| - "BD", |
58 |
| - "BG", |
59 |
| - "BO", |
60 |
| - "BR", |
61 |
| - "CA", |
62 |
| - "CL", |
63 |
| - "CN", |
64 |
| - "CO", |
65 |
| - "CR", |
66 |
| - "CZ", |
67 |
| - "DE", |
68 |
| - "EC", |
69 |
| - "FR", |
70 |
| - "GB", |
71 |
| - "GE", |
72 |
| - "GH", |
73 |
| - "GN", |
74 |
| - "HK", |
75 |
| - "ID", |
76 |
| - "IL", |
77 |
| - "IN", |
78 |
| - "IQ", |
79 |
| - "JP" |
80 |
| - ] |
81 |
| - for i in p_list: |
82 |
| - if i['country'] in countries: |
83 |
| - # print(i['country']) |
84 |
| - np_list.append(i) |
85 |
| - # np_list.append(i) |
86 |
| - proxy = [] |
87 |
| - fast_proxy = sorted(np_list, key=lambda k: k['response_time']) |
88 |
| - for p in fast_proxy: |
89 |
| - proxy.append(str(p['host']) + ':' + str(p['port'])) |
90 |
| - return proxy |
91 |
| - |
92 |
| - |
93 |
| -def getNames(): |
94 |
| - last_name_url = 'https://www.momjunction.com/articles/popular-indian-last-names-for-your-baby_00334734/' |
95 |
| - first_name_url = 'https://www.momjunction.com/articles/indian-baby-boy-names-with-meanings_00349318/' |
96 |
| - retrieveNames(last_name_url, 'last_name') |
97 |
| - retrieveNames(first_name_url, 'first_name') |
98 |
| - |
99 |
| - |
100 |
| -def sign(first_names, last_names, proxies, use_proxy, url): |
101 |
| - if use_proxy == 1: |
102 |
| - for proxy in proxies: |
103 |
| - fname = random.choice(first_names).strip() |
104 |
| - lname = random.choice(last_names).strip() |
105 |
| - email = fname + lname + str(random.randint(0, 220000)) + '@gmail.com' |
106 |
| - |
107 |
| - data = { |
108 |
| - 'firstName': fname, |
109 |
| - 'lastName': lname, |
110 |
| - 'email': email |
111 |
| - } |
112 |
| - |
113 |
| - # random.shuffle(proxies) |
114 |
| - |
115 |
| - firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX |
116 |
| - firefox_capabilities['marionette'] = True |
117 |
| - |
118 |
| - firefox_capabilities['proxy'] = { |
119 |
| - "proxyType": "MANUAL", |
120 |
| - "httpProxy": proxy, |
121 |
| - "ftpProxy": proxy, |
122 |
| - "sslProxy": proxy |
123 |
| - } |
124 |
| - browser = webdriver.Firefox(capabilities=firefox_capabilities) |
125 |
| - |
126 |
| - try: |
127 |
| - # proxy = '45.236.88.42:8880' |
128 |
| - print('Using Proxy: ', proxy) |
129 |
| - browser.set_page_load_timeout(90) |
130 |
| - |
131 |
| - browser.get(url) |
132 |
| - for key in data: |
133 |
| - a = browser.find_element_by_name(key) |
134 |
| - a.send_keys(data[key]) |
135 |
| - |
136 |
| - try: |
137 |
| - b = browser.find_element_by_name('marketingCommsConsent.consentGiven') |
138 |
| - b.click() |
139 |
| - b.submit() |
140 |
| - except: |
141 |
| - a.submit() |
142 |
| - |
143 |
| - print("Signed by: ", fname, lname) |
144 |
| - print() |
145 |
| - # x = input() |
146 |
| - |
147 |
| - time.sleep(3) |
148 |
| - browser.quit() |
149 |
| - |
150 |
| - except: |
151 |
| - browser.quit() |
152 |
| - # traceback.print_exc() |
153 |
| - print('skipping this proxy') |
154 |
| - continue |
| 11 | +# def retrieveNames(url, file_name): |
| 12 | +# user_agent = { |
| 13 | +# 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0' |
| 14 | +# } |
| 15 | +# |
| 16 | +# res = requests.get(url, headers=user_agent) |
| 17 | +# soup = beautifulsoup(res.content, 'html5lib') |
| 18 | +# |
| 19 | +# with open(file_name, 'w+', encoding='utf-8') as x: |
| 20 | +# for line in list(soup.find_all('h3')): |
| 21 | +# line = str(line).strip('<h3>') |
| 22 | +# line = str(line).strip('</h3>') |
| 23 | +# |
| 24 | +# line = re.sub('\d+. ', '', line) |
| 25 | +# line = line.strip(':') |
| 26 | +# line = line.strip(". ") |
| 27 | +# x.writelines(str(line) + '\n') |
| 28 | + |
| 29 | +# def getNames(): |
| 30 | +# last_name_url = 'https://www.momjunction.com/articles/popular-indian-last-names-for-your-baby_00334734/' |
| 31 | +# first_name_url = 'https://www.momjunction.com/articles/indian-baby-boy-names-with-meanings_00349318/' |
| 32 | +# retrieveNames(last_name_url, 'last_name') |
| 33 | +# retrieveNames(first_name_url, 'first_name') |
| 34 | + |
| 35 | + |
| 36 | +def sign(browser): |
| 37 | + fname = Faker().first_name() |
| 38 | + lname = Faker().last_name() |
| 39 | + randemail = fname + lname + str(random.randint(0, 50000)) + '@gmail.com' |
| 40 | + |
| 41 | + print("Using: ", fname, lname, randemail) |
| 42 | + |
| 43 | + fnamebox = browser.find_element_by_name('firstName') |
| 44 | + lnamebox = browser.find_element_by_name("lastName") |
| 45 | + emailbox = browser.find_element_by_name("email") |
| 46 | + publiccheck = browser.find_element_by_name("public") |
| 47 | + |
| 48 | + # This will not work |
| 49 | + # fnamebox.send_keys(fname) |
| 50 | + # time.sleep(1) |
| 51 | + # lnamebox.send_keys(lname) |
| 52 | + # time.sleep(1) |
| 53 | + # emailbox.send_keys(randemail) |
| 54 | + # time.sleep(1) |
| 55 | + # publiccheck.click() |
| 56 | + # time.sleep(1) |
| 57 | + # emailbox.submit() |
| 58 | + # time.sleep(1) |
| 59 | + |
| 60 | + # this will work |
| 61 | + for k in fname: |
| 62 | + fnamebox.send_keys(k) |
| 63 | + # time.sleep(.1) |
| 64 | + |
| 65 | + for k in lname: |
| 66 | + lnamebox.send_keys(k) |
| 67 | + # time.sleep(.1) |
| 68 | + |
| 69 | + for k in randemail: |
| 70 | + emailbox.send_keys(k) |
| 71 | + # time.sleep(.1) |
| 72 | + |
| 73 | + publiccheck.click() |
| 74 | + emailbox.submit() |
| 75 | + time.sleep(3) |
| 76 | + browser.delete_all_cookies() |
| 77 | + |
| 78 | + |
| 79 | +def start(test=0, pnum=0): |
| 80 | + print(""" |
| 81 | + ____ _ ____ _ |
| 82 | + / ___|(_) __ _ _ __ | __ ) ___ | |_ |
| 83 | + \___ \| |/ _` | '_ \| _ \ / _ \| __| |
| 84 | + ___) | | (_| | | | | |_) | (_) | |_ |
| 85 | + |____/|_|\__, |_| |_|____/ \___/ \__| |
| 86 | + |___/ |
| 87 | + """) |
| 88 | + print("Starting...") |
| 89 | + |
| 90 | + if not test: |
| 91 | + url = input("Enter url: ") |
155 | 92 | else:
|
156 |
| - fname = random.choice(first_names).strip() |
157 |
| - lname = random.choice(last_names).strip() |
158 |
| - email = fname + lname + str(random.randint(0, 220000)) + '@gmail.com' |
159 |
| - |
160 |
| - data = { |
161 |
| - 'firstName': fname, |
162 |
| - 'lastName': lname, |
163 |
| - 'email': email |
164 |
| - } |
165 |
| - |
166 |
| - |
167 |
| - # url = 'https://www.change.org/p/free-nazanin-ratcliffe?source_location=discover_feed' |
168 |
| - |
169 |
| - # random.shuffle(proxies) |
170 |
| - browser = webdriver.Firefox() |
171 |
| - |
| 93 | + url = 'https://www.change.org/p/realme-mobiles-release-the-flashtool-for-realme-devices' |
| 94 | + |
| 95 | + os_name = platform.system() |
| 96 | + os_arch, t = platform.architecture() |
| 97 | + |
| 98 | + if os_name == 'Linux': |
| 99 | + if os_arch == "64bit": |
| 100 | + loc = './geckodriver_L64' |
| 101 | + else: |
| 102 | + loc = './geckodriver_L32' |
| 103 | + if os_name == "Windows": |
| 104 | + if os_arch == "64bit": |
| 105 | + loc = './geckodriver_W64' |
| 106 | + else: |
| 107 | + loc = './geckodriver_W32' |
| 108 | + |
| 109 | + # these are the workarounds for not getting flagged as bot |
| 110 | + # UA = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0" |
| 111 | + # profile = webdriver.FirefoxProfile('/home/hritwik/.mozilla/firefox/zufq32k3.New') |
| 112 | + profile = webdriver.FirefoxProfile() |
| 113 | + # profile.set_preference("general.useragent.override", UA) |
| 114 | + profile.set_preference("dom.webdriver.enabled", False) |
| 115 | + profile.set_preference('useAutomationExtension', False) # this is must |
| 116 | + profile.set_preference('devtools.jsonview.enabled', False) |
| 117 | + profile.update_preferences() |
| 118 | + |
| 119 | + browser = webdriver.Firefox(profile, executable_path=loc) |
| 120 | + |
| 121 | + for _ in range(1, 200): |
172 | 122 | try:
|
173 |
| - browser.set_page_load_timeout(30) |
174 | 123 | browser.get(url)
|
175 |
| - for key in data: |
176 |
| - a = browser.find_element_by_name(key) |
177 |
| - a.send_keys(data[key]) |
178 |
| - |
179 |
| - try: |
180 |
| - b = browser.find_element_by_name('marketingCommsConsent.consentGiven') |
181 |
| - b.click() |
182 |
| - b.submit() |
183 |
| - except: |
184 |
| - a.submit() |
| 124 | + sign(browser) |
| 125 | + except: |
| 126 | + if test: |
| 127 | + traceback.print_exc() |
185 | 128 |
|
186 |
| - print("filled by: ", fname, lname) |
187 |
| - time.sleep(3) |
188 |
| - browser.quit() |
| 129 | + browser.delete_all_cookies() |
| 130 | + print("Error filling form. Refreshing...") |
189 | 131 |
|
190 |
| - except: |
191 |
| - browser.quit() |
192 |
| - return |
193 |
| - |
194 |
| - |
195 |
| -def start(): |
196 |
| - first_names = open('first_name', 'r').readlines() |
197 |
| - last_names = open('last_name', 'r').readlines() |
198 |
| - proxies = fate_proxy() |
199 |
| - |
200 |
| - up = int(input("Do you want to use proxies?.\n" |
201 |
| - "Only use proxies when your normal connection is blocked\n" |
202 |
| - "since proxies are very slow.\n" |
203 |
| - "1== Yes, 0 == NO\n")) |
204 |
| - |
205 |
| - # url = 'https://www.change.org/p/realme-mobiles-release-the-flashtool-for-realme-devices' |
206 |
| - url = input('Enter change.org url to sign') |
207 |
| - |
208 |
| - for x in range(200): |
209 |
| - try: |
210 |
| - sign(first_names, last_names, proxies, up, url) |
211 |
| - except: |
212 |
| - print("timeout") |
213 |
| - continue |
214 | 132 |
|
| 133 | +if os.path.isfile('./test_bit'): |
| 134 | + test = 1 |
| 135 | +else: |
| 136 | + test = 0 |
215 | 137 |
|
216 |
| -start() |
| 138 | +try: |
| 139 | + start(test=test) |
| 140 | +except: |
| 141 | + if test: |
| 142 | + traceback.print_exc() |
| 143 | + print("Exiting...") |
| 144 | + exit(0) |
0 commit comments