Update app.py
Browse files
app.py
CHANGED
@@ -3,36 +3,48 @@ import requests
|
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
6 |
-
#
|
7 |
-
#
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
}
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
@app.route('/', methods=['GET', 'POST'])
|
17 |
def home():
|
18 |
url = ''
|
19 |
-
|
20 |
error = ''
|
21 |
-
|
22 |
if request.method == 'POST':
|
23 |
url = request.form.get('url')
|
24 |
-
if not url.startswith((
|
25 |
-
url =
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
if __name__ == '__main__':
|
38 |
app.run(debug=True)
|
|
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
6 |
+
# List of free public SOCKS5 proxies.
|
7 |
+
# You can update this list from free proxy sources periodically.
|
8 |
+
proxies_list = [
|
9 |
+
"socks5h://104.248.63.15:30588",
|
10 |
+
"socks5h://149.154.159.5:1080",
|
11 |
+
"socks5h://165.231.86.172:9050",
|
12 |
+
# ...add more if needed
|
13 |
+
]
|
14 |
|
15 |
+
def get_working_proxy():
|
16 |
+
for proxy in proxies_list:
|
17 |
+
try:
|
18 |
+
r = requests.get("https://httpbin.org/ip", proxies={"http": proxy, "https": proxy}, timeout=5)
|
19 |
+
if r.status_code == 200:
|
20 |
+
return proxy
|
21 |
+
except:
|
22 |
+
continue
|
23 |
+
return None
|
24 |
|
25 |
@app.route('/', methods=['GET', 'POST'])
|
26 |
def home():
|
27 |
url = ''
|
28 |
+
content = ''
|
29 |
error = ''
|
30 |
+
|
31 |
if request.method == 'POST':
|
32 |
url = request.form.get('url')
|
33 |
+
if not url.startswith(("http://", "https://")):
|
34 |
+
url = "http://" + url
|
35 |
+
|
36 |
+
proxy = get_working_proxy()
|
37 |
+
if not proxy:
|
38 |
+
error = "No working free SOCKS5 proxy found. Try again later."
|
39 |
+
else:
|
40 |
+
try:
|
41 |
+
r = requests.get(url, proxies={"http": proxy, "https": proxy}, timeout=10)
|
42 |
+
r.raise_for_status()
|
43 |
+
content = r.text
|
44 |
+
except Exception as e:
|
45 |
+
error = f"Error fetching URL via proxy {proxy}: {e}"
|
46 |
+
|
47 |
+
return render_template('index.html', url=url, content=content, error=error)
|
48 |
|
49 |
if __name__ == '__main__':
|
50 |
app.run(debug=True)
|