File size: 11,348 Bytes
4cfb2fd 7dc92ea 4cfb2fd ab278b2 040d2d8 b0ec203 7dc92ea bb31e94 4cfb2fd 040d2d8 4cfb2fd 99d92f1 4cfb2fd 040d2d8 9e9ea88 06e8bf7 040d2d8 1fa5297 040d2d8 4cfb2fd 040d2d8 b47ada4 4cfb2fd bb31e94 4cfb2fd 8701b0f 4cfb2fd 040d2d8 bb31e94 b47ada4 4cfb2fd bb31e94 4cfb2fd 9e9ea88 4cfb2fd 7dc92ea 4cfb2fd 7dc92ea 4cfb2fd 7dc92ea 99d92f1 7dc92ea 4cfb2fd 7dc92ea 99d92f1 7dc92ea 4cfb2fd 7dc92ea 99d92f1 7dc92ea 4cfb2fd 7dc92ea 99d92f1 7dc92ea 4cfb2fd 7dc92ea 99d92f1 7dc92ea 99d92f1 b47ada4 9e9ea88 b47ada4 9e9ea88 7d31244 040d2d8 99d92f1 040d2d8 99d92f1 9e9ea88 040d2d8 9e9ea88 040d2d8 9e9ea88 1fa5297 4cfb2fd 9e9ea88 1fa5297 9e9ea88 4cfb2fd 9e9ea88 4cfb2fd 1fa5297 4cfb2fd b0ec203 6bd7823 7d31244 1fa5297 7d31244 6bd7823 7d31244 4cfb2fd 7dc92ea 4cfb2fd 8309a97 7dc92ea 6bd7823 bb31e94 7dc92ea b0ec203 bb31e94 8309a97 4cfb2fd bb31e94 4cfb2fd 9e9ea88 4cfb2fd 8309a97 7dc92ea bb31e94 8309a97 4cfb2fd bb31e94 2f4c69a 99d92f1 7dc92ea b47ada4 bb31e94 9e9ea88 bb31e94 fca1113 |
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
import requests
from bs4 import BeautifulSoup
from httpx import Client, HTTPError
from pydantic import BaseModel
import re
import urllib.parse
import fake_useragent as fake
import random
from dotenv import load_dotenv
import os
from faker import Faker
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import time
from webdriver_manager.chrome import ChromeDriverManager
from tqdm import tqdm
import threading
import gradio as gr
load_dotenv()
class Proxy(BaseModel):
ip: str
port: str
type: str
class VisitRequest(BaseModel):
url: str
count: int
delay: int
parallel_processes: int
def get_random_proxy():
try:
response = requests.get("https://uhhy-fsfsfs.hf.space/valid")
response.raise_for_status()
proxies = response.text.splitlines()
if proxies:
return random.choice(proxies)
else:
return None
except Exception as e:
print(f"Error getting proxy: {e}")
return None
def get_proxies():
try:
proxies = []
for _ in range(5):
proxy = get_random_proxy()
if proxy:
proxies.append(proxy)
return "\n".join(proxies)
except Exception as e:
return str(e)
def rotate_ip():
try:
fake = Faker()
random_ip = fake.ipv4()
headers = {
"X-Forwarded-For": random_ip,
"Client-IP": random_ip,
"X-Real-IP": random_ip
}
proxy = get_random_proxy()
if not proxy:
return "No proxy available."
return proxy
except Exception as e:
return str(e)
def extract_video_id(url: str, platform: str) -> str:
url = urllib.parse.unquote(url)
if platform == "instagram":
match = re.search(r"instagram\.com/reel/([^/?]+)", url)
elif platform == "tiktok":
match = re.search(r"tiktok\.com/@[^/]+/video/(\d+)", url)
elif platform == "youtube":
match = re.search(r"youtube\.com/watch\?v=([^&]+)", url)
elif platform == "facebook":
match = re.search(r"facebook\.com/.*/videos/(\d+)", url)
elif platform == "twitch":
match = re.search(r"twitch\.tv/videos/(\d+)", url)
elif platform == "spotify":
match = re.search(r"spotify\.com/track/([^/?]+)", url)
else:
match = None
if match:
return match.group(1)
else:
return None
def instagram_login(username: str, password: str):
login_url = "https://www.instagram.com/accounts/login/ajax/"
session = requests.Session()
response = session.get("https://www.instagram.com/", headers={"User-Agent": "Mozilla/5.0"})
soup = BeautifulSoup(response.text, "html.parser")
csrf_token = soup.find("meta", {"name": "csrf-token"})["content"]
login_data = {
"username": username,
"enc_password": f"#PWD_INSTAGRAM_BROWSER:0:&:{password}"
}
headers = {
"User-Agent": "Mozilla/5.0",
"X-CSRFToken": csrf_token,
"X-Requested-With": "XMLHttpRequest"
}
response = session.post(login_url, data=login_data, headers=headers)
if response.status_code == 200 and response.json().get("authenticated"):
return session
else:
raise HTTPError("Authentication failed")
def tiktok_login(username: str, password: str):
login_url = "https://www.tiktok.com/login/"
session = requests.Session()
login_data = {
"username": username,
"password": password
}
response = session.post(login_url, data=login_data)
if response.status_code == 200:
return session
else:
raise HTTPError("Authentication failed")
def youtube_login(username: str, password: str):
login_url = "https://accounts.google.com/ServiceLogin"
session = requests.Session()
login_data = {
"username": username,
"password": password
}
response = session.post(login_url, data=login_data)
if response.status_code == 200:
return session
else:
raise HTTPError("Authentication failed")
def facebook_login(username: str, password: str):
login_url = "https://www.facebook.com/login"
session = requests.Session()
login_data = {
"email": username,
"pass": password
}
response = session.post(login_url, data=login_data)
if response.status_code == 200:
return session
else:
raise HTTPError("Authentication failed")
def twitch_login(username: str, password: str):
login_url = "https://www.twitch.tv/login"
session = requests.Session()
login_data = {
"login": username,
"password": password
}
response = session.post(login_url, data=login_data)
if response.status_code == 200:
return session
else:
raise HTTPError("Authentication failed")
def spotify_login(username: str, password: str):
login_url = "https://accounts.spotify.com/api/token"
session = requests.Session()
login_data = {
"username": username,
"password": password
}
response = session.post(login_url, data=login_data)
if response.status_code == 200:
return session
else:
raise HTTPError("Authentication failed")
def simulate_view(url: str, proxy: str, session: Client, delay: int):
webdriver.DesiredCapabilities.CHROME['proxy'] = {
"httpProxy": proxy,
"ftpProxy": proxy,
"sslProxy": proxy,
"proxyType": "MANUAL",
}
options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_argument("--disable-popup-blocking")
options.add_argument("--disable-infobars")
options.add_argument("--disable-web-security")
options.add_argument("--ignore-certificate-errors")
options.add_argument("--disable-notifications")
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--mute-audio")
options.add_argument('--ignore-ssl-errors=yes')
options.add_argument('--ignore-certificate-errors')
driver = webdriver.Chrome(options=options)
try:
fake = Faker()
fake_ipv4 = fake.ipv4()
headers = {
"User-Agent": fake.user_agent(),
"X-Forwarded-For": fake_ipv4,
"Client-IP": fake_ipv4,
"X-Real-IP": fake_ipv4
}
driver.get(url)
try:
not_now = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'mt3GC')))
a = not_now.find_elements(By.TAG_NAME, "button")[1]
actions = ActionChains(driver)
actions.click(a)
actions.perform()
except:
pass
time.sleep(delay)
return True
except Exception as e:
print(f"Error simulating view: {e}")
return False
finally:
driver.quit()
def simulate_views_background(url: str, count: int, delay: int, session: Client = None):
proxy = get_random_proxy()
if not proxy:
print("No proxy available.")
return
successful_views = 0
failed_views = 0
for i in tqdm(range(count), desc=f"Simulating views for {url}"):
try:
success = simulate_view(url, proxy, session, delay)
if success:
successful_views += 1
else:
failed_views += 1
remaining_views = count - i - 1
print(f"Successful: {successful_views}, Failed: {failed_views}, Remaining: {remaining_views}, Time Remaining: {((count - i - 1) * delay) / 60:.2f} minutes")
except Exception as e:
failed_views += 1
remaining_views = count - i - 1
print(f"Successful: {successful_views}, Failed: {failed_views}, Remaining: {remaining_views}, Time Remaining: {((count - i - 1) * delay) / 60:.2f} minutes")
def simulate_views_endpoint(request: VisitRequest):
try:
session = None
threading.Thread(
target=simulate_views_background,
args=(
request.url,
request.count,
request.delay,
session,
)
).start()
return "Views simulation started in the background."
except Exception as e:
return str(e)
def simulate(urls: str, count: int, delay: int, parallel_processes: int):
try:
session = None
for url in urls.split("\n"):
for _ in range(parallel_processes):
threading.Thread(
target=simulate_views_background,
args=(
url,
count,
delay,
session
)
).start()
return "Simulations started in the background."
except Exception as e:
return str(e)
def rand(min, max):
return random.randint(min, max)
with gr.Blocks(css="""
body {
background-color: #f0f0f0;
font-family: sans-serif;
}
.container {
background-color: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
text-align: center;
animation: fadeIn 1s ease-in-out;
}
h1 {
color: #333;
margin-bottom: 20px;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
form {
display: flex;
flex-direction: column;
width: 350px;
}
label {
margin-bottom: 5px;
font-weight: bold;
}
input[type="text"],
textarea,
select,
input[type="number"] {
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ddd;
border-radius: 5px;
}
input[type="submit"] {
background-color: #007bff;
color: #fff;
border: none;
padding: 12px 20px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
""") as interface:
urls = gr.Textbox(label="Website URLs or IP addresses (one per line)")
count = gr.Number(label="Number of Views", value=1)
delay = gr.Number(label="Delay (seconds)", value=1)
parallel_processes = gr.Number(label="Parallel Processes", value=1)
simulate_btn = gr.Button("Simulate")
output = gr.Textbox(label="Output")
simulate_btn.click(
fn=simulate,
inputs=[urls, count, delay, parallel_processes],
outputs=output,
)
interface.launch(server_name="0.0.0.0", server_port=7860, share=True) |