mirror of
https://github.com/tghw/macproxy.git
synced 2024-12-12 13:29:27 +00:00
Revise tags and get url separately.
This commit is contained in:
parent
43c008917b
commit
8f6a0f4fb1
@ -2,7 +2,7 @@ from bs4 import BeautifulSoup
|
||||
|
||||
def macify(html):
|
||||
soup = BeautifulSoup(html)
|
||||
for tag in soup(['script', 'link', 'style', 'img', 'noscript']):
|
||||
for tag in soup(['script', 'link', 'style', 'noscript']):
|
||||
tag.extract()
|
||||
for tag in soup(['div', 'span']):
|
||||
tag.replaceWithChildren()
|
||||
|
9
proxy.py
9
proxy.py
@ -8,15 +8,16 @@ session = requests.Session()
|
||||
@app.route('/', defaults={'path': ''}, methods=['GET'])
|
||||
@app.route('/<path:path>', methods=['GET'])
|
||||
def get(path):
|
||||
resp = session.get(path, params=request.args)
|
||||
url = request.url
|
||||
resp = session.get(url, params=request.args)
|
||||
return macify(resp.content), resp.status_code
|
||||
|
||||
@app.route('/', defaults={'path': ''}, methods=['POST'])
|
||||
@app.route('/<path:path>', methods=['POST'])
|
||||
def post(path):
|
||||
resp = session.post(path, data=request.form, allow_redirects=True)
|
||||
url = request.url
|
||||
resp = session.post(url, data=request.form, allow_redirects=True)
|
||||
return macify(resp.content), resp.status_code
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.debug = True
|
||||
app.run()
|
||||
app.run(host='0.0.0.0', port=5000)
|
||||
|
Loading…
Reference in New Issue
Block a user