edwagbb commited on
Commit
aac89d0
·
1 Parent(s): 2c62d5a

Update proxy.py

Browse files
Files changed (1) hide show
  1. proxy.py +4 -3
proxy.py CHANGED
@@ -1,16 +1,17 @@
1
  from flask import Flask, request, Response
2
  import requests
 
3
 
4
  app = Flask(__name__)
5
 
6
- @app.route('/proxy/<path:url>', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'])
7
  def proxy(url):
8
  req_method = request.method
9
  req_headers = {key: value for key, value in request.headers if key != 'Host'}
10
  req_data = request.get_data()
11
 
12
- resp = requests.request(method=req_method,
13
- url=f'https://{url}',
14
  headers=req_headers,
15
  data=req_data,
16
  stream=True)
 
1
  from flask import Flask, request, Response
2
  import requests
3
+ import cloudscraper
4
 
5
  app = Flask(__name__)
6
 
7
+ @app.route('/proxy/<scheme>/<path:url>', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'])
8
  def proxy(url):
9
  req_method = request.method
10
  req_headers = {key: value for key, value in request.headers if key != 'Host'}
11
  req_data = request.get_data()
12
 
13
+ resp = cloudscraper.create_scraper(interpreter='nodejs').request(method=req_method,
14
+ url=f'{scheme}://{url}',
15
  headers=req_headers,
16
  data=req_data,
17
  stream=True)