Update app.py
Browse files
app.py
CHANGED
|
@@ -37,14 +37,13 @@ def get_random_proxy():
|
|
| 37 |
try:
|
| 38 |
response = requests.get("https://uhhy-fsfsfs.hf.space/valid")
|
| 39 |
soup = BeautifulSoup(response.text, 'html.parser')
|
| 40 |
-
proxy_rows = soup.find_all('tr')[1:]
|
| 41 |
proxies = []
|
| 42 |
for row in proxy_rows:
|
| 43 |
columns = row.find_all('td')
|
| 44 |
ip = columns[0].text
|
| 45 |
port = columns[1].text
|
| 46 |
-
|
| 47 |
-
proxies.append(Proxy(ip=ip, port=port, type=proxy_type))
|
| 48 |
if proxies:
|
| 49 |
return random.choice(proxies)
|
| 50 |
else:
|
|
@@ -59,7 +58,7 @@ def get_proxies():
|
|
| 59 |
for _ in range(5):
|
| 60 |
proxy = get_random_proxy()
|
| 61 |
if proxy:
|
| 62 |
-
proxies.append(
|
| 63 |
return "\n".join(proxies)
|
| 64 |
except Exception as e:
|
| 65 |
return str(e)
|
|
@@ -76,7 +75,7 @@ def rotate_ip():
|
|
| 76 |
proxy = get_random_proxy()
|
| 77 |
if not proxy:
|
| 78 |
return "No proxy available."
|
| 79 |
-
return
|
| 80 |
except Exception as e:
|
| 81 |
return str(e)
|
| 82 |
|
|
@@ -187,11 +186,11 @@ def spotify_login(username: str, password: str):
|
|
| 187 |
else:
|
| 188 |
raise HTTPError("Authentication failed")
|
| 189 |
|
| 190 |
-
def simulate_view(url: str, proxy:
|
| 191 |
webdriver.DesiredCapabilities.CHROME['proxy'] = {
|
| 192 |
-
"httpProxy":
|
| 193 |
-
"ftpProxy":
|
| 194 |
-
"sslProxy":
|
| 195 |
"proxyType": "MANUAL",
|
| 196 |
}
|
| 197 |
options = webdriver.ChromeOptions()
|
|
@@ -221,9 +220,6 @@ def simulate_view(url: str, proxy: Proxy, session: Client, delay: int):
|
|
| 221 |
"X-Real-IP": fake_ipv4
|
| 222 |
}
|
| 223 |
|
| 224 |
-
if proxy.type == "http" or proxy.type == "https":
|
| 225 |
-
session.get(url, headers=headers, proxies={"http": f"http://{proxy.ip}:{proxy.port}", "https": f"https://{proxy.ip}:{proxy.port}"})
|
| 226 |
-
|
| 227 |
driver.get(url)
|
| 228 |
|
| 229 |
try:
|
|
@@ -367,8 +363,7 @@ with gr.Blocks(css="""
|
|
| 367 |
}
|
| 368 |
}
|
| 369 |
""") as interface:
|
| 370 |
-
|
| 371 |
-
gr.HTML("""
|
| 372 |
<div class="container">
|
| 373 |
<h1>Website Traffic Simulator</h1>
|
| 374 |
<form action="/simulate" method="post">
|
|
@@ -384,12 +379,10 @@ with gr.Blocks(css="""
|
|
| 384 |
</form>
|
| 385 |
</div>
|
| 386 |
""")
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
delay = gr.Number(label="Delay (seconds)", value=1)
|
| 392 |
-
parallel_processes = gr.Number(label="Parallel Processes", value=1)
|
| 393 |
simulate_btn = gr.Button("Simulate")
|
| 394 |
output = gr.Textbox(label="Output")
|
| 395 |
|
|
|
|
| 37 |
try:
|
| 38 |
response = requests.get("https://uhhy-fsfsfs.hf.space/valid")
|
| 39 |
soup = BeautifulSoup(response.text, 'html.parser')
|
| 40 |
+
proxy_rows = soup.find_all('tr')[1:]
|
| 41 |
proxies = []
|
| 42 |
for row in proxy_rows:
|
| 43 |
columns = row.find_all('td')
|
| 44 |
ip = columns[0].text
|
| 45 |
port = columns[1].text
|
| 46 |
+
proxies.append(f"{ip}:{port}")
|
|
|
|
| 47 |
if proxies:
|
| 48 |
return random.choice(proxies)
|
| 49 |
else:
|
|
|
|
| 58 |
for _ in range(5):
|
| 59 |
proxy = get_random_proxy()
|
| 60 |
if proxy:
|
| 61 |
+
proxies.append(proxy)
|
| 62 |
return "\n".join(proxies)
|
| 63 |
except Exception as e:
|
| 64 |
return str(e)
|
|
|
|
| 75 |
proxy = get_random_proxy()
|
| 76 |
if not proxy:
|
| 77 |
return "No proxy available."
|
| 78 |
+
return proxy
|
| 79 |
except Exception as e:
|
| 80 |
return str(e)
|
| 81 |
|
|
|
|
| 186 |
else:
|
| 187 |
raise HTTPError("Authentication failed")
|
| 188 |
|
| 189 |
+
def simulate_view(url: str, proxy: str, session: Client, delay: int):
|
| 190 |
webdriver.DesiredCapabilities.CHROME['proxy'] = {
|
| 191 |
+
"httpProxy": proxy,
|
| 192 |
+
"ftpProxy": proxy,
|
| 193 |
+
"sslProxy": proxy,
|
| 194 |
"proxyType": "MANUAL",
|
| 195 |
}
|
| 196 |
options = webdriver.ChromeOptions()
|
|
|
|
| 220 |
"X-Real-IP": fake_ipv4
|
| 221 |
}
|
| 222 |
|
|
|
|
|
|
|
|
|
|
| 223 |
driver.get(url)
|
| 224 |
|
| 225 |
try:
|
|
|
|
| 363 |
}
|
| 364 |
}
|
| 365 |
""") as interface:
|
| 366 |
+
gr.HTML("""
|
|
|
|
| 367 |
<div class="container">
|
| 368 |
<h1>Website Traffic Simulator</h1>
|
| 369 |
<form action="/simulate" method="post">
|
|
|
|
| 379 |
</form>
|
| 380 |
</div>
|
| 381 |
""")
|
| 382 |
+
urls = gr.Textbox(label="Website URLs or IP addresses (one per line)")
|
| 383 |
+
count = gr.Number(label="Number of Views", value=1)
|
| 384 |
+
delay = gr.Number(label="Delay (seconds)", value=1)
|
| 385 |
+
parallel_processes = gr.Number(label="Parallel Processes", value=1)
|
|
|
|
|
|
|
| 386 |
simulate_btn = gr.Button("Simulate")
|
| 387 |
output = gr.Textbox(label="Output")
|
| 388 |
|