File size: 1,485 Bytes
ddafe1f
 
 
 
 
f0d04a9
 
 
 
 
 
 
 
ddafe1f
f0d04a9
 
 
 
 
 
 
 
 
ddafe1f
 
 
 
f0d04a9
ddafe1f
f0d04a9
ddafe1f
 
f0d04a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ddafe1f
 
3209381
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
from flask import Flask, render_template, request
import requests

app = Flask(__name__)

# List of free public SOCKS5 proxies.
# You can update this list from free proxy sources periodically.
proxies_list = [
    "socks5h://104.248.63.15:30588",
    "socks5h://149.154.159.5:1080",
    "socks5h://165.231.86.172:9050",
    # ...add more if needed
]

def get_working_proxy():
    for proxy in proxies_list:
        try:
            r = requests.get("https://httpbin.org/ip", proxies={"http": proxy, "https": proxy}, timeout=5)
            if r.status_code == 200:
                return proxy
        except:
            continue
    return None

@app.route('/', methods=['GET', 'POST'])
def home():
    url = ''
    content = ''
    error = ''

    if request.method == 'POST':
        url = request.form.get('url')
        if not url.startswith(("http://", "https://")):
            url = "http://" + url

        proxy = get_working_proxy()
        if not proxy:
            error = "No working free SOCKS5 proxy found. Try again later."
        else:
            try:
                r = requests.get(url, proxies={"http": proxy, "https": proxy}, timeout=10)
                r.raise_for_status()
                content = r.text
            except Exception as e:
                error = f"Error fetching URL via proxy {proxy}: {e}"

    return render_template('index.html', url=url, content=content, error=error)

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=7860)