Spaces:
Paused
Paused
File size: 4,304 Bytes
db2962a 02f60c1 db2962a 02f60c1 db2962a 7a1a6f3 db2962a 7a1a6f3 db2962a 7a1a6f3 db2962a 7a1a6f3 02f60c1 7a1a6f3 02f60c1 7a1a6f3 02f60c1 db2962a 02f60c1 db2962a 02f60c1 7a1a6f3 db2962a 02f60c1 db2962a 02f60c1 db2962a 02f60c1 db2962a 02f60c1 db2962a 7a1a6f3 db2962a 3280640 db2962a 02f60c1 db2962a 02f60c1 db2962a | 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 | import gradio as gr
import requests
from concurrent.futures import ThreadPoolExecutor
import time
from datetime import datetime
def check_proxy(proxy):
proxy_dict = {"http": f"http://{proxy}", "https": f"http://{proxy}"}
address, port = proxy.split(':')
start_time = time.time()
try:
response = requests.get("http://www.google.com", proxies=proxy_dict, timeout=5)
response_time = (time.time() - start_time) * 1000 # Convert to ms
status = "On"
except Exception as e:
response_time = 0
status = "Off"
# Call ip-api.com for country and ISP with error handling
try:
ip_info = requests.get(f"http://ip-api.com/json/{address}", timeout=5).json()
country = ip_info.get("country", "Unknown")
isp = ip_info.get("isp", "Unknown")
except Exception as e:
country = "Unknown"
isp = "Unknown"
return {"address": address, "port": port, "status": status, "response_time": round(response_time, 2), "protocol": "HTTP", "country": country, "isp": isp}
def check_proxies(proxy_list):
if not proxy_list:
return [["No proxies provided", "", "", "", "", "", 0]]
proxies = proxy_list.splitlines()
results = []
with ThreadPoolExecutor(max_workers=5) as executor: # Increased workers for better performance
results = list(executor.map(check_proxy, proxies))
return [[r["address"], r["port"], r["status"], r["protocol"], r["country"], r["isp"], r["response_time"]] for r in results]
def filter_proxies(proxies, status_filter, protocol_filter, country_filter):
if not proxies:
return []
filtered = []
for proxy in proxies:
if (status_filter == "All" or proxy[2] == status_filter) and \
(protocol_filter == "All" or proxy[3] == protocol_filter) and \
(not country_filter or country_filter.lower() in proxy[4].lower()):
filtered.append(proxy)
return filtered
# Create Gradio interface
with gr.Blocks(title="Proxy Checker") as demo:
gr.Markdown(f"# Proxy Checker - {datetime(2025, 8, 22, 10, 40).strftime('%I:%M %p, %d/%m/%Y +07')}")
with gr.Row():
with gr.Column():
proxy_input = gr.Textbox(label="Enter proxy list (one per line)", lines=10, placeholder="Example:\n39.104.16.201:80\n87.239.31.42:80")
check_button = gr.Button("Start Checking")
stop_button = gr.Button("Stop Checking", interactive=False)
continue_button = gr.Button("Continue Checking", interactive=False)
with gr.Column():
with gr.Row():
status_filter = gr.Radio(["All", "On", "Off"], label="Status", value="All")
protocol_filter = gr.CheckboxGroup(["HTTP", "HTTPS", "SOCKS4", "SOCKS5"], label="Protocol", value=["HTTP"])
country_filter = gr.Textbox(label="Filter by Country", placeholder="Example: RU, US")
output_table = gr.Dataframe(
label="Results",
headers=["Address", "Port", "Status", "Protocol", "Country", "ISP", "Response Time (ms)"],
interactive=False
)
# Logic for checking
def update_table(proxy_list):
try:
results = check_proxies(proxy_list)
return gr.Dataframe.update(value=results)
except Exception as e:
return gr.Dataframe.update(value=[["Error", "", "", "", "", "", 0]], visible=True)
check_button.click(
fn=update_table,
inputs=proxy_input,
outputs=output_table
)
# Update filters
def update_filter(status, protocols, country):
current_data = output_table.value or []
return gr.Dataframe.update(value=filter_proxies(current_data, status, protocols, country))
status_filter.change(
fn=update_filter,
inputs=[status_filter, protocol_filter, country_filter],
outputs=output_table
)
protocol_filter.change(
fn=update_filter,
inputs=[status_filter, protocol_filter, country_filter],
outputs=output_table
)
country_filter.change(
fn=update_filter,
inputs=[status_filter, protocol_filter, country_filter],
outputs=output_table
)
demo.launch() |