-
Notifications
You must be signed in to change notification settings - Fork 492
/
v2.py
221 lines (167 loc) · 8.64 KB
/
v2.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# I used tekky's script because I was too lazy to do it, it's just a simple script.
from time import sleep
from datetime import datetime
from os import system, name as os_name
from base64 import b64encode
from io import BytesIO
from requests import get, post, Session
from re import findall
from selenium import webdriver
from colorama import Fore, init, Style
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By
text = """
███████ ███████ ███████ ██████ ██ ██
███ ██ ██ ██ ██ ██ ██
███ █████ █████ ██ ██ ████
███ ██ ██ ██ ██ ██
███████ ███████ ██ ██████ ██ """
class Zefoy:
def __init__(self) -> None:
self.captcha_box = '/html/body/div[5]/div[2]/form/div/div'
self.driver = self.setup_browser()
self.sent = 0
self.option = None
self.clear = system('cls' if os_name == 'nt' else 'clear')
self.captcha_box = '/html/body/div[5]/div[2]/form/div/div'
self.xpaths = {
"followers" : "/html/body/div[6]/div/div[2]/div/div/div[2]/div/button",
"hearts" : "/html/body/div[6]/div/div[2]/div/div/div[3]/div/button",
"comment_hearts": "/html/body/div[6]/div/div[2]/div/div/div[4]/div/button",
"views" : "/html/body/div[6]/div/div[2]/div/div/div[5]/div/button",
"shares" : "/html/body/div[6]/div/div[2]/div/div/div[6]/div/button",
"favorites" : "/html/body/div[6]/div/div[2]/div/div/div[7]/div/button",
}
self.tasks = {
1: (('self.driver.find_element(By.XPATH, self.xpaths["followers"]).click()', "7"), "c2VuZF9mb2xsb3dlcnNfdGlrdG9r"),
2: (('self.driver.find_element(By.XPATH, self.xpaths["hearts"]).click()', "8"), "c2VuZE9nb2xsb3dlcnNfdGlrdG9r"),
3: (('self.driver.find_element(By.XPATH, self.xpaths["comment_hearts"]).click()', "9"), "c2VuZC9mb2xsb3dlcnNfdGlrdG9r"),
4: (('self.driver.find_element(By.XPATH, self.xpaths["views"]).click()', "10"), "c2VuZC9mb2xeb3dlcnNfdGlrdG9V"),
5: (('self.driver.find_element(By.XPATH, self.xpaths["shares"]).click()', "11"), "c2VuZC9mb2xsb3dlcnNfdGlrdG9s"),
6: (('self.driver.find_element(By.XPATH, self.xpaths["favorites"]).click()', "12"), "c2VuZF9mb2xsb3dlcnNfdGlrdG9L")
}
def setup_browser(self) -> WebDriver:
options = Options()
options.add_experimental_option("detach", True)
options.add_experimental_option("excludeSwitches", ["enable-logging"])
return webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))
def solve(debug) -> dict:
session = Session()
session.headers = {
'authority': 'zefoy.com',
'origin': 'https://zefoy.com',
'authority': 'zefoy.com',
'cp-extension-installed': 'Yes',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
}
while True:
source_code = str(session.get('https://zefoy.com').text).replace('&', '&')
captcha_token = findall(r'<input type="hidden" name="(.*)">', source_code)
if 'token' in captcha_token:
captcha_token.remove('token')
captcha_url = findall(r'img src="([^"]*)"', source_code)[0]
token_answer = findall(r'type="text" name="(.*)" oninput="this.value', source_code)[0]
encoded_image = b64encode(BytesIO(session.get('https://zefoy.com' + captcha_url).content).read()).decode('utf-8')
captcha_answer = post(f"https://platipus9999.pythonanywhere.com/", json={'captcha': encoded_image, 'current_time': datetime.now().strftime("%H:%M:%S")}).json()["result"]
sleep(1)
data = {
token_answer: captcha_answer,
}
for values in captcha_token:
token, value = values.split('" value="')
data[token] = value
else:
data['token'] = ''
response = session.post('https://zefoy.com', data = data).text
try:
findall(r'remove-spaces" name="(.*)" placeholder', response)[0]
return {'name':'PHPSESSID', 'value': session.cookies.get('PHPSESSID')}
except:
pass
def send_bot(self, search_button, url_box, vid_info, div):
element = self.driver.find_element(By.XPATH, url_box)
element.clear()
element.send_keys(vid_info)
self.driver.find_element(By.XPATH, search_button).click()
sleep(3)
ratelimit_seconds, full = self.check_submit()
if "(s)" in str(full):
self.main_sleep(ratelimit_seconds)
self.driver.find_element(By.XPATH, search_button).click()
sleep(2)
sleep(3)
send_button = f'/html/body/div[{div}]/div/div/div[1]/div/form/button'
self.driver.find_element(By.XPATH, send_button).click()
self.sent += 1
print(self._print(f"Sent {self.sent} times."))
sleep(4)
self.send_bot(search_button, url_box, vid_info, div)
def main_sleep(self, delay):
while delay != 0:
sleep(1)
delay -= 1
self.change_title(f"TikTok Zefoy Automator using Zefoy.com / Cooldown: {delay}s / Github: @useragents")
def convert(self, min: int, sec: int) -> int:
return min * 60 + sec + 4 if min != 0 else sec + 4
def check_submit(self):
remaining = f'//*[@id="{self.tasks[self.option][1]}"]/span'
try:
element = self.driver.find_element(By.XPATH, remaining)
except:
return None, None
if "READY" in element.text:
return True, True
if "seconds for your next submit" in element.text:
output = element.text.split("Please wait ")[1].split(" for")[0]
minutes = element.text.split("Please wait ")[1].split(" ")[0]
seconds = element.text.split("(s) ")[1].split(" ")[0]
sleep_duration = self.convert(int(minutes), int(seconds))
return sleep_duration, output
return element.text, None
def check_status(self):
statuses = {}
for thing in self.xpaths:
value = self.xpaths[thing]
element = self.driver.find_element(By.XPATH, value)
if not element.is_enabled():
statuses.update({thing: f"{Fore.RED}[OFFLINE]"})
else:
statuses.update({thing: f"{Fore.GREEN}[WORKS]"})
return statuses
def _print(self, msg, status = "-"):
return f" {Fore.WHITE}[{Fore.CYAN}{status}{Fore.WHITE}] {msg}"
def change_title(self, arg):
system(f'title {arg}' if os_name == 'nt' else '')
def wait_for_xpath(self, xpath):
while True:
try:
self.driver.find_element(By.XPATH, xpath)
break
except:
pass
def main(self):
self.clear
print(Fore.CYAN + text+ "\n")
self.driver.get("https://zefoy.com")
print(self._print("Solving The Captcha"))
self.driver.add_cookie(self.solve())
self.driver.refresh()
self.wait_for_xpath(self.xpaths["views"])
self.clear
status = self.check_status()
print('\n')
counter = 1
for thing in status:
print(self._print(f"{thing} {status[thing]}", counter))
counter += 1
self.option = int(input("\n" + self._print(f"")))
video_url = input("\n" + self._print(f"Username/VideoURL: "))
task, div = self.tasks[self.option][0]; eval(task)
video_url_box = f'/html/body/div[{div}]/div/form/div/input'
search_box = f'/html/body/div[{div}]/div/form/div/div/button'
self.send_bot(search_box, video_url_box, video_url, div)
if __name__ == "__main__":
Zefoy().main()