Untitled
unknown
python
2 years ago
966 B
2
Indexable
Never
import requests import http.server from urllib.parse import urlparse class transHandler(http.server.BaseHTTPRequestHandler): header = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0" } url = "" def do_GET(self): self.send_response(200) self.end_headers() result = urlparse(self.path) try: info = requests.get( url=f"{self.url}&{result.query}", headers=self.header, timeout=5 ) except: pass else: try: self.wfile.write(info.content) except BrokenPipeError: pass else: self.wfile.flush() def run(server_class=http.server.HTTPServer, handler_class=transHandler): server_address = ("localhost", 0) httpd = server_class(server_address, handler_class) httpd.serve_forever() run()