用 python 或者其他语言写个 proxy ,转发链接,前几天刚用 GPT 帮我做了个
```
# -*- coding: utf-8 -*-
import re
import requests
from flask import Flask, Response, request
HOST = '127.0.0.1' # 监听地址,建议监听本地然后由 web 服务器反代
PORT = 7997 # 监听端口
app = Flask(__name__)
regex = r"( http|https):\/(?=\w)"
requests.packages.urllib3.disable_warnings()
@
app.route('/')
def index():
return "hello world!"
@
app.route('/<path:path>', methods=['GET', 'POST'])
def handler(path):
# 构建目标 URL
if path:
target_url = re.sub(regex, r"\1://", path)
else:
return "No URL provided", 400
print(target_url)
resp = requests.request(method=request.method,url=target_url,verify=False,timeout=5)
# 将收到的响应转发回客户端
excluded_headers = ['connection']
headers = [(name, value) for (name, value) in resp.raw.headers.items()
if name.lower() not in excluded_headers]
response = Response(resp.content, resp.status_code, headers)
return response
# nohup python3
proxy.py > proxy.log 2>&1 &
app.debug = True
if __name__ == '__main__':
app.run(host=HOST, port=PORT)
```