Uhhy commited on
Commit
040d2d8
·
verified ·
1 Parent(s): 8701b0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +363 -175
app.py CHANGED
@@ -1,20 +1,23 @@
1
  import requests
2
  from bs4 import BeautifulSoup
3
- from fastapi import FastAPI, BackgroundTasks, HTTPException, Form
4
  from fastapi.responses import PlainTextResponse, HTMLResponse
5
  from fastapi.staticfiles import StaticFiles
6
  from pydantic import BaseModel
7
  import re
8
- from concurrent.futures import ThreadPoolExecutor
9
  import urllib.parse
10
- import gradio as gr
11
  import fake_useragent as fake
12
  import random
13
  from dotenv import load_dotenv
14
  import os
15
- from tqdm import tqdm
16
  from faker import Faker
17
- import faker as fakexd
 
 
 
 
 
 
18
 
19
  load_dotenv()
20
 
@@ -23,6 +26,7 @@ app = FastAPI()
23
  class Proxy(BaseModel):
24
  ip: str
25
  port: str
 
26
 
27
  class VisitRequest(BaseModel):
28
  url: str
@@ -34,27 +38,39 @@ class VisitRequest(BaseModel):
34
  app.mount("/static", StaticFiles(directory="static"), name="static")
35
 
36
  def get_random_proxy():
37
- pubproxy_url = "http://pubproxy.com/api/proxy?limit=1&type=http"
38
- response = requests.get(pubproxy_url, verify=False)
39
- data = response.json()
40
- if data['data']:
41
- proxy_data = data['data'][0]
42
- return f"{proxy_data['ip']}:{proxy_data['port']}"
43
- return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  @app.get("/get_proxies", response_class=PlainTextResponse)
46
  def get_proxies():
47
  try:
48
  proxies = []
49
- pubproxy_url = "http://pubproxy.com/api/proxy?limit=5&type=http"
50
- response = requests.get(pubproxy_url, verify=False)
51
- data = response.json()
52
-
53
- for proxy_data in data['data']:
54
- ip, port = proxy_data['ipPort'].split(":")
55
- proxy = f"{ip}:{port}"
56
- proxies.append(proxy)
57
-
58
  return "\n".join(proxies)
59
  except Exception as e:
60
  return PlainTextResponse(str(e), status_code=500)
@@ -64,24 +80,15 @@ def rotate_ip():
64
  try:
65
  fake = Faker()
66
  random_ip = fake.ipv4()
67
-
68
  headers = {
69
  "X-Forwarded-For": random_ip,
70
  "Client-IP": random_ip,
71
  "X-Real-IP": random_ip
72
  }
73
-
74
- test_url = "http://pubproxy.com/api/proxy?limit=1&type=http&https=true&speed=60"
75
- response = requests.get(test_url, headers=headers, verify=False)
76
- data = response.json()
77
-
78
- proxies = []
79
- for proxy_data in data['data']:
80
- ip, port = proxy_data['ipPort'].split(":")
81
- proxy = f"{ip}:{port}"
82
- proxies.append(proxy)
83
-
84
- return "\n".join(proxies)
85
  except Exception as e:
86
  return PlainTextResponse(str(e), status_code=500)
87
 
@@ -101,7 +108,6 @@ def extract_video_id(url: str, platform: str) -> str:
101
  match = re.search(r"spotify\.com/track/([^/?]+)", url)
102
  else:
103
  match = None
104
-
105
  if match:
106
  return match.group(1)
107
  else:
@@ -110,24 +116,19 @@ def extract_video_id(url: str, platform: str) -> str:
110
  def instagram_login(username: str, password: str):
111
  login_url = "https://www.instagram.com/accounts/login/ajax/"
112
  session = requests.Session()
113
-
114
  response = session.get("https://www.instagram.com/", headers={"User-Agent": "Mozilla/5.0"})
115
  soup = BeautifulSoup(response.text, "html.parser")
116
  csrf_token = soup.find("meta", {"name": "csrf-token"})["content"]
117
-
118
  login_data = {
119
  "username": username,
120
  "enc_password": f"#PWD_INSTAGRAM_BROWSER:0:&:{password}"
121
  }
122
-
123
  headers = {
124
  "User-Agent": "Mozilla/5.0",
125
  "X-CSRFToken": csrf_token,
126
  "X-Requested-With": "XMLHttpRequest"
127
  }
128
-
129
  response = session.post(login_url, data=login_data, headers=headers)
130
-
131
  if response.status_code == 200 and response.json().get("authenticated"):
132
  return session
133
  else:
@@ -136,14 +137,11 @@ def instagram_login(username: str, password: str):
136
  def tiktok_login(username: str, password: str):
137
  login_url = "https://www.tiktok.com/login/"
138
  session = requests.Session()
139
-
140
  login_data = {
141
  "username": username,
142
  "password": password
143
  }
144
-
145
  response = session.post(login_url, data=login_data)
146
-
147
  if response.status_code == 200:
148
  return session
149
  else:
@@ -152,14 +150,11 @@ def tiktok_login(username: str, password: str):
152
  def youtube_login(username: str, password: str):
153
  login_url = "https://accounts.google.com/ServiceLogin"
154
  session = requests.Session()
155
-
156
  login_data = {
157
  "username": username,
158
  "password": password
159
  }
160
-
161
  response = session.post(login_url, data=login_data)
162
-
163
  if response.status_code == 200:
164
  return session
165
  else:
@@ -168,14 +163,11 @@ def youtube_login(username: str, password: str):
168
  def facebook_login(username: str, password: str):
169
  login_url = "https://www.facebook.com/login"
170
  session = requests.Session()
171
-
172
  login_data = {
173
  "email": username,
174
  "pass": password
175
  }
176
-
177
  response = session.post(login_url, data=login_data)
178
-
179
  if response.status_code == 200:
180
  return session
181
  else:
@@ -184,14 +176,11 @@ def facebook_login(username: str, password: str):
184
  def twitch_login(username: str, password: str):
185
  login_url = "https://www.twitch.tv/login"
186
  session = requests.Session()
187
-
188
  login_data = {
189
  "login": username,
190
  "password": password
191
  }
192
-
193
  response = session.post(login_url, data=login_data)
194
-
195
  if response.status_code == 200:
196
  return session
197
  else:
@@ -200,166 +189,367 @@ def twitch_login(username: str, password: str):
200
  def spotify_login(username: str, password: str):
201
  login_url = "https://accounts.spotify.com/api/token"
202
  session = requests.Session()
203
-
204
  login_data = {
205
  "username": username,
206
  "password": password
207
  }
208
-
209
  response = session.post(login_url, data=login_data)
210
-
211
  if response.status_code == 200:
212
  return session
213
  else:
214
  raise HTTPException(status_code=401, detail="Authentication failed")
215
 
216
- def simulate_instagram_view(video_id: str, proxy: str, session: requests.Session):
217
- proxies = {
218
- "http": f"http://{proxy}"
219
- }
220
- fake = Faker()
221
- fake_ipv4 = fake.ipv4()
222
- headers = {
223
- "User-Agent": fake.user_agent(),
224
- "X-Forwarded-For": fake_ipv4,
225
- "Client-IP": fake_ipv4,
226
- "X-Real-IP": fake_ipv4
227
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  try:
 
 
 
 
 
 
 
 
229
  view_url = f"https://www.instagram.com/reel/{video_id}"
230
- response = session.get(view_url, headers=headers, proxies=proxies)
231
- embed_link = f"https://www.instagram.com/p/{video_id}/embed/?autoplay=true"
232
- embed_link_with_start = f"{embed_link}?start={rand(4, 8)}"
233
- print(embed_link_with_start)
234
- except Exception as e:
235
- print(f"Error in simulate_instagram_view: {e}")
236
 
237
- def simulate_tiktok_view(video_id: str, proxy: str, session: requests.Session):
238
- proxies = {
239
- "http": f"http://{proxy}"
240
- }
241
- fake = Faker()
242
- fake_ipv4 = fake.ipv4()
243
- headers = {
244
- "User-Agent": fake.user_agent(),
245
- "X-Forwarded-For": fake_ipv4,
246
- "Client-IP": fake_ipv4,
247
- "X-Real-IP": fake_ipv4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  try:
 
 
 
 
 
 
 
 
250
  view_url = f"https://www.tiktok.com/@user/video/{video_id}"
251
- response = session.get(view_url, headers=headers, proxies=proxies)
252
- embed_link = f"https://www.tiktok.com/embed/v/{video_id}?autoplay=true"
253
- embed_link_with_start = f"{embed_link}?start={rand(4, 8)}"
254
- print(embed_link_with_start)
255
- except Exception as e:
256
- print(f"Error in simulate_tiktok_view: {e}")
257
 
258
- def simulate_youtube_view(video_id: str, proxy: str, session: requests.Session):
259
- proxies = {
260
- "http": f"http://{proxy}"
261
- }
262
- fake = Faker()
263
- fake_ipv4 = fake.ipv4()
264
- headers = {
265
- "User-Agent": fake.user_agent(),
266
- "X-Forwarded-For": fake_ipv4,
267
- "Client-IP": fake_ipv4,
268
- "X-Real-IP": fake_ipv4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  try:
 
 
 
 
 
 
 
 
271
  view_url = f"https://www.youtube.com/watch?v={video_id}"
272
- response = session.get(view_url, headers=headers, proxies=proxies)
273
- embed_link = f"https://www.youtube.com/embed/{video_id}?autoplay=true"
274
- embed_link_with_start = f"{embed_link}?controls=0&start={rand(4, 8)}"
275
- print(embed_link_with_start)
276
- except Exception as e:
277
- print(f"Error in simulate_youtube_view: {e}")
278
 
279
- def simulate_facebook_view(video_id: str, proxy: str, session: requests.Session):
280
- proxies = {
281
- "http": f"http://{proxy}"
282
- }
283
- fake = Faker()
284
- fake_ipv4 = fake.ipv4()
285
- headers = {
286
- "User-Agent": fake.user_agent(),
287
- "X-Forwarded-For": fake_ipv4,
288
- "Client-IP": fake_ipv4,
289
- "X-Real-IP": fake_ipv4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  try:
 
 
 
 
 
 
 
 
292
  view_url = f"https://www.facebook.com/{video_id}"
293
- response = session.get(view_url, headers=headers, proxies=proxies)
294
- embed_link = f"https://www.facebook.com/plugins/video.php?href=https://www.facebook.com/{video_id}/&show_text=0&width=560&height=315&autoplay=true"
295
- embed_link_with_start = f"{embed_link}&start={rand(4, 8)}"
296
- print(embed_link_with_start)
297
- except Exception as e:
298
- print(f"Error in simulate_facebook_view: {e}")
299
 
300
- def simulate_twitch_view(video_id: str, proxy: str, session: requests.Session):
301
- proxies = {
302
- "http": f"http://{proxy}"
303
- }
304
- fake = Faker()
305
- fake_ipv4 = fake.ipv4()
306
- headers = {
307
- "User-Agent": fake.user_agent(),
308
- "X-Forwarded-For": fake_ipv4,
309
- "Client-IP": fake_ipv4,
310
- "X-Real-IP": fake_ipv4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  try:
 
 
 
 
 
 
 
 
313
  view_url = f"https://www.twitch.tv/videos/{video_id}"
314
- response = session.get(view_url, headers=headers, proxies=proxies)
315
- embed_link = f"https://player.twitch.tv/?video=v{video_id}&parent=www.example.com&autoplay=true&muted=false"
316
- embed_link_with_start = f"{embed_link}&start={rand(4, 8)}"
317
- print(embed_link_with_start)
318
- except Exception as e:
319
- print(f"Error in simulate_twitch_view: {e}")
320
 
321
- def simulate_spotify_view(video_id: str, proxy: str, session: requests.Session):
322
- proxies = {
323
- "http": f"http://{proxy}"
324
- }
325
- fake = Faker()
326
- fake_ipv4 = fake.ipv4()
327
- headers = {
328
- "User-Agent": fake.user_agent(),
329
- "X-Forwarded-For": fake_ipv4,
330
- "Client-IP": fake_ipv4,
331
- "X-Real-IP": fake_ipv4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  try:
 
 
 
 
 
 
 
 
334
  view_url = f"https://open.spotify.com/track/{video_id}"
335
- response = session.get(view_url, headers=headers, proxies=proxies)
336
- embed_link = f"https://open.spotify.com/embed/track/{video_id}?autoplay=true"
337
- embed_link_with_start = f"{embed_link}?start={rand(4, 8)}"
338
- print(embed_link_with_start)
 
 
 
 
 
 
 
 
 
 
 
 
339
  except Exception as e:
340
- print(f"Error in simulate_spotify_view: {e}")
 
 
341
 
342
  def simulate_views(url: str, platform: str, count: int, delay: int, parallel_processes: int, session: requests.Session):
343
  video_id = extract_video_id(url, platform)
344
  proxy = get_random_proxy()
345
-
346
  if not proxy:
347
- print("No proxy available.")
348
  return
349
-
350
- for _ in tqdm(range(count), desc=f"Simulating views for {url}"):
351
- if platform == "instagram":
352
- simulate_instagram_view(video_id, proxy, session)
353
- elif platform == "tiktok":
354
- simulate_tiktok_view(video_id, proxy, session)
355
- elif platform == "youtube":
356
- simulate_youtube_view(video_id, proxy, session)
357
- elif platform == "facebook":
358
- simulate_facebook_view(video_id, proxy, session)
359
- elif platform == "twitch":
360
- simulate_twitch_view(video_id, proxy, session)
361
- elif platform == "spotify":
362
- simulate_spotify_view(video_id, proxy, session)
 
 
363
 
364
  @app.post("/simulate_views")
365
  async def simulate_views_endpoint(request: VisitRequest):
@@ -412,10 +602,8 @@ async def simulate(urls: str = Form(...), platform: str = Form(...), count: int
412
  for index, url in enumerate(urls.split("\n")):
413
  try:
414
  simulate_views(url, platform, count, delay, parallel_processes, session)
415
- print(f"Simulation started for URL {index+1}: {url}")
416
  except Exception as e:
417
- print(f"Error processing URL {index+1}: {e}")
418
-
419
  return PlainTextResponse("Simulation completed.")
420
  else:
421
  return PlainTextResponse("Credentials not found for this platform.")
 
1
  import requests
2
  from bs4 import BeautifulSoup
3
+ from fastapi import FastAPI, HTTPException, Form
4
  from fastapi.responses import PlainTextResponse, HTMLResponse
5
  from fastapi.staticfiles import StaticFiles
6
  from pydantic import BaseModel
7
  import re
 
8
  import urllib.parse
 
9
  import fake_useragent as fake
10
  import random
11
  from dotenv import load_dotenv
12
  import os
 
13
  from faker import Faker
14
+ from selenium import webdriver
15
+ from selenium.webdriver.common.by import By
16
+ from selenium.webdriver.support.ui import WebDriverWait
17
+ from selenium.webdriver.support import expected_conditions as EC
18
+ from selenium.webdriver.common.action_chains import ActionChains
19
+ import time
20
+ from webdriver_manager.chrome import ChromeDriverManager
21
 
22
  load_dotenv()
23
 
 
26
  class Proxy(BaseModel):
27
  ip: str
28
  port: str
29
+ type: str
30
 
31
  class VisitRequest(BaseModel):
32
  url: str
 
38
  app.mount("/static", StaticFiles(directory="static"), name="static")
39
 
40
  def get_random_proxy():
41
+ try:
42
+ options = webdriver.ChromeOptions()
43
+ options.add_argument('--headless')
44
+ options.add_argument('--disable-gpu')
45
+ options.add_argument('--no-sandbox')
46
+ driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
47
+ driver.get("https://uhhy-fsfsfs.hf.space/valid")
48
+ WebDriverWait(driver, 10).until(
49
+ EC.presence_of_element_located((By.CSS_SELECTOR, "table tbody tr"))
50
+ )
51
+ proxy_elements = driver.find_elements(By.CSS_SELECTOR, "table tbody tr")
52
+ proxies = []
53
+ for element in proxy_elements:
54
+ ip = element.find_element(By.CSS_SELECTOR, "td:nth-child(1)").text
55
+ port = element.find_element(By.CSS_SELECTOR, "td:nth-child(2)").text
56
+ proxy_type = element.find_element(By.CSS_SELECTOR, "td:nth-child(3)").text.lower()
57
+ proxies.append(Proxy(ip=ip, port=port, type=proxy_type))
58
+ driver.quit()
59
+ if proxies:
60
+ return random.choice(proxies)
61
+ else:
62
+ return None
63
+ except Exception as e:
64
+ return None
65
 
66
  @app.get("/get_proxies", response_class=PlainTextResponse)
67
  def get_proxies():
68
  try:
69
  proxies = []
70
+ for _ in range(5):
71
+ proxy = get_random_proxy()
72
+ if proxy:
73
+ proxies.append(f"{proxy.ip}:{proxy.port} ({proxy.type})")
 
 
 
 
 
74
  return "\n".join(proxies)
75
  except Exception as e:
76
  return PlainTextResponse(str(e), status_code=500)
 
80
  try:
81
  fake = Faker()
82
  random_ip = fake.ipv4()
 
83
  headers = {
84
  "X-Forwarded-For": random_ip,
85
  "Client-IP": random_ip,
86
  "X-Real-IP": random_ip
87
  }
88
+ proxy = get_random_proxy()
89
+ if not proxy:
90
+ return PlainTextResponse("No proxy available.", status_code=500)
91
+ return PlainTextResponse(f"{proxy.ip}:{proxy.port} ({proxy.type})")
 
 
 
 
 
 
 
 
92
  except Exception as e:
93
  return PlainTextResponse(str(e), status_code=500)
94
 
 
108
  match = re.search(r"spotify\.com/track/([^/?]+)", url)
109
  else:
110
  match = None
 
111
  if match:
112
  return match.group(1)
113
  else:
 
116
  def instagram_login(username: str, password: str):
117
  login_url = "https://www.instagram.com/accounts/login/ajax/"
118
  session = requests.Session()
 
119
  response = session.get("https://www.instagram.com/", headers={"User-Agent": "Mozilla/5.0"})
120
  soup = BeautifulSoup(response.text, "html.parser")
121
  csrf_token = soup.find("meta", {"name": "csrf-token"})["content"]
 
122
  login_data = {
123
  "username": username,
124
  "enc_password": f"#PWD_INSTAGRAM_BROWSER:0:&:{password}"
125
  }
 
126
  headers = {
127
  "User-Agent": "Mozilla/5.0",
128
  "X-CSRFToken": csrf_token,
129
  "X-Requested-With": "XMLHttpRequest"
130
  }
 
131
  response = session.post(login_url, data=login_data, headers=headers)
 
132
  if response.status_code == 200 and response.json().get("authenticated"):
133
  return session
134
  else:
 
137
  def tiktok_login(username: str, password: str):
138
  login_url = "https://www.tiktok.com/login/"
139
  session = requests.Session()
 
140
  login_data = {
141
  "username": username,
142
  "password": password
143
  }
 
144
  response = session.post(login_url, data=login_data)
 
145
  if response.status_code == 200:
146
  return session
147
  else:
 
150
  def youtube_login(username: str, password: str):
151
  login_url = "https://accounts.google.com/ServiceLogin"
152
  session = requests.Session()
 
153
  login_data = {
154
  "username": username,
155
  "password": password
156
  }
 
157
  response = session.post(login_url, data=login_data)
 
158
  if response.status_code == 200:
159
  return session
160
  else:
 
163
  def facebook_login(username: str, password: str):
164
  login_url = "https://www.facebook.com/login"
165
  session = requests.Session()
 
166
  login_data = {
167
  "email": username,
168
  "pass": password
169
  }
 
170
  response = session.post(login_url, data=login_data)
 
171
  if response.status_code == 200:
172
  return session
173
  else:
 
176
  def twitch_login(username: str, password: str):
177
  login_url = "https://www.twitch.tv/login"
178
  session = requests.Session()
 
179
  login_data = {
180
  "login": username,
181
  "password": password
182
  }
 
183
  response = session.post(login_url, data=login_data)
 
184
  if response.status_code == 200:
185
  return session
186
  else:
 
189
  def spotify_login(username: str, password: str):
190
  login_url = "https://accounts.spotify.com/api/token"
191
  session = requests.Session()
 
192
  login_data = {
193
  "username": username,
194
  "password": password
195
  }
 
196
  response = session.post(login_url, data=login_data)
 
197
  if response.status_code == 200:
198
  return session
199
  else:
200
  raise HTTPException(status_code=401, detail="Authentication failed")
201
 
202
+ def simulate_instagram_view(video_id: str, proxy: Proxy, session: requests.Session):
203
+ webdriver.DesiredCapabilities.CHROME['proxy'] = {
204
+ "httpProxy": f"{proxy.ip}:{proxy.port}",
205
+ "ftpProxy": f"{proxy.ip}:{proxy.port}",
206
+ "sslProxy": f"{proxy.ip}:{proxy.port}",
207
+ "proxyType": "MANUAL",
 
 
 
 
 
208
  }
209
+ options = webdriver.ChromeOptions()
210
+ options.add_argument("--headless")
211
+ options.add_argument("--disable-blink-features=AutomationControlled")
212
+ options.add_argument("--disable-popup-blocking")
213
+ options.add_argument("--disable-infobars")
214
+ options.add_argument("--disable-web-security")
215
+ options.add_argument("--ignore-certificate-errors")
216
+ options.add_argument("--disable-notifications")
217
+ options.add_argument("--disable-extensions")
218
+ options.add_argument("--disable-gpu")
219
+ options.add_argument("--no-sandbox")
220
+ options.add_argument("--disable-dev-shm-usage")
221
+ options.add_argument("--mute-audio")
222
+ options.add_argument('--ignore-ssl-errors=yes')
223
+ options.add_argument('--ignore-certificate-errors')
224
+ driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
225
+
226
  try:
227
+ fake = Faker()
228
+ fake_ipv4 = fake.ipv4()
229
+ headers = {
230
+ "User-Agent": fake.user_agent(),
231
+ "X-Forwarded-For": fake_ipv4,
232
+ "Client-IP": fake_ipv4,
233
+ "X-Real-IP": fake_ipv4
234
+ }
235
  view_url = f"https://www.instagram.com/reel/{video_id}"
 
 
 
 
 
 
236
 
237
+ if proxy.type == "http" or proxy.type == "https":
238
+ response = session.get(view_url, headers=headers, proxies={"http": f"http://{proxy.ip}:{proxy.port}", "https": f"https://{proxy.ip}:{proxy.port}"})
239
+
240
+ driver.get(view_url)
241
+
242
+ try:
243
+ not_now = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'mt3GC')))
244
+ a = not_now.find_elements(By.TAG_NAME, "button")[1]
245
+ actions = ActionChains(driver)
246
+ actions.click(a)
247
+ actions.perform()
248
+ except:
249
+ pass
250
+
251
+ time.sleep(rand(10, 20))
252
+ except Exception as e:
253
+ pass
254
+ finally:
255
+ driver.quit()
256
+
257
+ def simulate_tiktok_view(video_id: str, proxy: Proxy, session: requests.Session):
258
+ webdriver.DesiredCapabilities.CHROME['proxy'] = {
259
+ "httpProxy": f"{proxy.ip}:{proxy.port}",
260
+ "ftpProxy": f"{proxy.ip}:{proxy.port}",
261
+ "sslProxy": f"{proxy.ip}:{proxy.port}",
262
+ "proxyType": "MANUAL",
263
  }
264
+ options = webdriver.ChromeOptions()
265
+ options.add_argument("--headless")
266
+ options.add_argument("--disable-blink-features=AutomationControlled")
267
+ options.add_argument("--disable-popup-blocking")
268
+ options.add_argument("--disable-infobars")
269
+ options.add_argument("--disable-web-security")
270
+ options.add_argument("--ignore-certificate-errors")
271
+ options.add_argument("--disable-notifications")
272
+ options.add_argument("--disable-extensions")
273
+ options.add_argument("--disable-gpu")
274
+ options.add_argument("--no-sandbox")
275
+ options.add_argument("--disable-dev-shm-usage")
276
+ options.add_argument("--mute-audio")
277
+ options.add_argument('--ignore-ssl-errors=yes')
278
+ options.add_argument('--ignore-certificate-errors')
279
+ driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
280
+
281
  try:
282
+ fake = Faker()
283
+ fake_ipv4 = fake.ipv4()
284
+ headers = {
285
+ "User-Agent": fake.user_agent(),
286
+ "X-Forwarded-For": fake_ipv4,
287
+ "Client-IP": fake_ipv4,
288
+ "X-Real-IP": fake_ipv4
289
+ }
290
  view_url = f"https://www.tiktok.com/@user/video/{video_id}"
 
 
 
 
 
 
291
 
292
+ if proxy.type == "http" or proxy.type == "https":
293
+ response = session.get(view_url, headers=headers, proxies={"http": f"http://{proxy.ip}:{proxy.port}", "https": f"https://{proxy.ip}:{proxy.port}"})
294
+
295
+ driver.get(view_url)
296
+
297
+ try:
298
+ not_now = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'mt3GC')))
299
+ a = not_now.find_elements(By.TAG_NAME, "button")[1]
300
+ actions = ActionChains(driver)
301
+ actions.click(a)
302
+ actions.perform()
303
+ except:
304
+ pass
305
+
306
+ time.sleep(rand(10, 20))
307
+ except Exception as e:
308
+ pass
309
+ finally:
310
+ driver.quit()
311
+
312
+ def simulate_youtube_view(video_id: str, proxy: Proxy, session: requests.Session):
313
+ webdriver.DesiredCapabilities.CHROME['proxy'] = {
314
+ "httpProxy": f"{proxy.ip}:{proxy.port}",
315
+ "ftpProxy": f"{proxy.ip}:{proxy.port}",
316
+ "sslProxy": f"{proxy.ip}:{proxy.port}",
317
+ "proxyType": "MANUAL",
318
  }
319
+ options = webdriver.ChromeOptions()
320
+ options.add_argument("--headless")
321
+ options.add_argument("--disable-blink-features=AutomationControlled")
322
+ options.add_argument("--disable-popup-blocking")
323
+ options.add_argument("--disable-infobars")
324
+ options.add_argument("--disable-web-security")
325
+ options.add_argument("--ignore-certificate-errors")
326
+ options.add_argument("--disable-notifications")
327
+ options.add_argument("--disable-extensions")
328
+ options.add_argument("--disable-gpu")
329
+ options.add_argument("--no-sandbox")
330
+ options.add_argument("--disable-dev-shm-usage")
331
+ options.add_argument("--mute-audio")
332
+ options.add_argument('--ignore-ssl-errors=yes')
333
+ options.add_argument('--ignore-certificate-errors')
334
+ driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
335
+
336
  try:
337
+ fake = Faker()
338
+ fake_ipv4 = fake.ipv4()
339
+ headers = {
340
+ "User-Agent": fake.user_agent(),
341
+ "X-Forwarded-For": fake_ipv4,
342
+ "Client-IP": fake_ipv4,
343
+ "X-Real-IP": fake_ipv4
344
+ }
345
  view_url = f"https://www.youtube.com/watch?v={video_id}"
 
 
 
 
 
 
346
 
347
+ if proxy.type == "http" or proxy.type == "https":
348
+ response = session.get(view_url, headers=headers, proxies={"http": f"http://{proxy.ip}:{proxy.port}", "https": f"https://{proxy.ip}:{proxy.port}"})
349
+
350
+ driver.get(view_url)
351
+
352
+ try:
353
+ not_now = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'mt3GC')))
354
+ a = not_now.find_elements(By.TAG_NAME, "button")[1]
355
+ actions = ActionChains(driver)
356
+ actions.click(a)
357
+ actions.perform()
358
+ except:
359
+ pass
360
+
361
+ time.sleep(rand(10, 20))
362
+ except Exception as e:
363
+ pass
364
+ finally:
365
+ driver.quit()
366
+
367
+ def simulate_facebook_view(video_id: str, proxy: Proxy, session: requests.Session):
368
+ webdriver.DesiredCapabilities.CHROME['proxy'] = {
369
+ "httpProxy": f"{proxy.ip}:{proxy.port}",
370
+ "ftpProxy": f"{proxy.ip}:{proxy.port}",
371
+ "sslProxy": f"{proxy.ip}:{proxy.port}",
372
+ "proxyType": "MANUAL",
373
  }
374
+ options = webdriver.ChromeOptions()
375
+ options.add_argument("--headless")
376
+ options.add_argument("--disable-blink-features=AutomationControlled")
377
+ options.add_argument("--disable-popup-blocking")
378
+ options.add_argument("--disable-infobars")
379
+ options.add_argument("--disable-web-security")
380
+ options.add_argument("--ignore-certificate-errors")
381
+ options.add_argument("--disable-notifications")
382
+ options.add_argument("--disable-extensions")
383
+ options.add_argument("--disable-gpu")
384
+ options.add_argument("--no-sandbox")
385
+ options.add_argument("--disable-dev-shm-usage")
386
+ options.add_argument("--mute-audio")
387
+ options.add_argument('--ignore-ssl-errors=yes')
388
+ options.add_argument('--ignore-certificate-errors')
389
+ driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
390
+
391
  try:
392
+ fake = Faker()
393
+ fake_ipv4 = fake.ipv4()
394
+ headers = {
395
+ "User-Agent": fake.user_agent(),
396
+ "X-Forwarded-For": fake_ipv4,
397
+ "Client-IP": fake_ipv4,
398
+ "X-Real-IP": fake_ipv4
399
+ }
400
  view_url = f"https://www.facebook.com/{video_id}"
 
 
 
 
 
 
401
 
402
+ if proxy.type == "http" or proxy.type == "https":
403
+ response = session.get(view_url, headers=headers, proxies={"http": f"http://{proxy.ip}:{proxy.port}", "https": f"https://{proxy.ip}:{proxy.port}"})
404
+
405
+ driver.get(view_url)
406
+
407
+ try:
408
+ not_now = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'mt3GC')))
409
+ a = not_now.find_elements(By.TAG_NAME, "button")[1]
410
+ actions = ActionChains(driver)
411
+ actions.click(a)
412
+ actions.perform()
413
+ except:
414
+ pass
415
+
416
+ time.sleep(rand(10, 20))
417
+ except Exception as e:
418
+ pass
419
+ finally:
420
+ driver.quit()
421
+
422
+ def simulate_twitch_view(video_id: str, proxy: Proxy, session: requests.Session):
423
+ webdriver.DesiredCapabilities.CHROME['proxy'] = {
424
+ "httpProxy": f"{proxy.ip}:{proxy.port}",
425
+ "ftpProxy": f"{proxy.ip}:{proxy.port}",
426
+ "sslProxy": f"{proxy.ip}:{proxy.port}",
427
+ "proxyType": "MANUAL",
428
  }
429
+ options = webdriver.ChromeOptions()
430
+ options.add_argument("--headless")
431
+ options.add_argument("--disable-blink-features=AutomationControlled")
432
+ options.add_argument("--disable-popup-blocking")
433
+ options.add_argument("--disable-infobars")
434
+ options.add_argument("--disable-web-security")
435
+ options.add_argument("--ignore-certificate-errors")
436
+ options.add_argument("--disable-notifications")
437
+ options.add_argument("--disable-extensions")
438
+ options.add_argument("--disable-gpu")
439
+ options.add_argument("--no-sandbox")
440
+ options.add_argument("--disable-dev-shm-usage")
441
+ options.add_argument("--mute-audio")
442
+ options.add_argument('--ignore-ssl-errors=yes')
443
+ options.add_argument('--ignore-certificate-errors')
444
+ driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
445
+
446
  try:
447
+ fake = Faker()
448
+ fake_ipv4 = fake.ipv4()
449
+ headers = {
450
+ "User-Agent": fake.user_agent(),
451
+ "X-Forwarded-For": fake_ipv4,
452
+ "Client-IP": fake_ipv4,
453
+ "X-Real-IP": fake_ipv4
454
+ }
455
  view_url = f"https://www.twitch.tv/videos/{video_id}"
 
 
 
 
 
 
456
 
457
+ if proxy.type == "http" or proxy.type == "https":
458
+ response = session.get(view_url, headers=headers, proxies={"http": f"http://{proxy.ip}:{proxy.port}", "https": f"https://{proxy.ip}:{proxy.port}"})
459
+
460
+ driver.get(view_url)
461
+
462
+ try:
463
+ not_now = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'mt3GC')))
464
+ a = not_now.find_elements(By.TAG_NAME, "button")[1]
465
+ actions = ActionChains(driver)
466
+ actions.click(a)
467
+ actions.perform()
468
+ except:
469
+ pass
470
+
471
+ time.sleep(rand(10, 20))
472
+ except Exception as e:
473
+ pass
474
+ finally:
475
+ driver.quit()
476
+
477
+ def simulate_spotify_view(video_id: str, proxy: Proxy, session: requests.Session):
478
+ webdriver.DesiredCapabilities.CHROME['proxy'] = {
479
+ "httpProxy": f"{proxy.ip}:{proxy.port}",
480
+ "ftpProxy": f"{proxy.ip}:{proxy.port}",
481
+ "sslProxy": f"{proxy.ip}:{proxy.port}",
482
+ "proxyType": "MANUAL",
483
  }
484
+ options = webdriver.ChromeOptions()
485
+ options.add_argument("--headless")
486
+ options.add_argument("--disable-blink-features=AutomationControlled")
487
+ options.add_argument("--disable-popup-blocking")
488
+ options.add_argument("--disable-infobars")
489
+ options.add_argument("--disable-web-security")
490
+ options.add_argument("--ignore-certificate-errors")
491
+ options.add_argument("--disable-notifications")
492
+ options.add_argument("--disable-extensions")
493
+ options.add_argument("--disable-gpu")
494
+ options.add_argument("--no-sandbox")
495
+ options.add_argument("--disable-dev-shm-usage")
496
+ options.add_argument("--mute-audio")
497
+ options.add_argument('--ignore-ssl-errors=yes')
498
+ options.add_argument('--ignore-certificate-errors')
499
+ driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
500
+
501
  try:
502
+ fake = Faker()
503
+ fake_ipv4 = fake.ipv4()
504
+ headers = {
505
+ "User-Agent": fake.user_agent(),
506
+ "X-Forwarded-For": fake_ipv4,
507
+ "Client-IP": fake_ipv4,
508
+ "X-Real-IP": fake_ipv4
509
+ }
510
  view_url = f"https://open.spotify.com/track/{video_id}"
511
+
512
+ if proxy.type == "http" or proxy.type == "https":
513
+ response = session.get(view_url, headers=headers, proxies={"http": f"http://{proxy.ip}:{proxy.port}", "https": f"https://{proxy.ip}:{proxy.port}"})
514
+
515
+ driver.get(view_url)
516
+
517
+ try:
518
+ not_now = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'mt3GC')))
519
+ a = not_now.find_elements(By.TAG_NAME, "button")[1]
520
+ actions = ActionChains(driver)
521
+ actions.click(a)
522
+ actions.perform()
523
+ except:
524
+ pass
525
+
526
+ time.sleep(rand(10, 20))
527
  except Exception as e:
528
+ pass
529
+ finally:
530
+ driver.quit()
531
 
532
  def simulate_views(url: str, platform: str, count: int, delay: int, parallel_processes: int, session: requests.Session):
533
  video_id = extract_video_id(url, platform)
534
  proxy = get_random_proxy()
 
535
  if not proxy:
 
536
  return
537
+ for _ in range(count):
538
+ try:
539
+ if platform == "instagram":
540
+ simulate_instagram_view(video_id, proxy, session)
541
+ elif platform == "tiktok":
542
+ simulate_tiktok_view(video_id, proxy, session)
543
+ elif platform == "youtube":
544
+ simulate_youtube_view(video_id, proxy, session)
545
+ elif platform == "facebook":
546
+ simulate_facebook_view(video_id, proxy, session)
547
+ elif platform == "twitch":
548
+ simulate_twitch_view(video_id, proxy, session)
549
+ elif platform == "spotify":
550
+ simulate_spotify_view(video_id, proxy, session)
551
+ except Exception as e:
552
+ pass
553
 
554
  @app.post("/simulate_views")
555
  async def simulate_views_endpoint(request: VisitRequest):
 
602
  for index, url in enumerate(urls.split("\n")):
603
  try:
604
  simulate_views(url, platform, count, delay, parallel_processes, session)
 
605
  except Exception as e:
606
+ pass
 
607
  return PlainTextResponse("Simulation completed.")
608
  else:
609
  return PlainTextResponse("Credentials not found for this platform.")