From 8f6a0f4fb1c2471a8e03115038e08711ccb3d76c Mon Sep 17 00:00:00 2001 From: "Tyler G. Hicks-Wright" Date: Thu, 12 Dec 2013 09:13:58 -0700 Subject: [PATCH] Revise tags and get url separately. --- macify.py | 4 ++-- proxy.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/macify.py b/macify.py index 1f2909a..83f7e74 100644 --- a/macify.py +++ b/macify.py @@ -1,8 +1,8 @@ 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() diff --git a/proxy.py b/proxy.py index 39b2df3..55762a0 100644 --- a/proxy.py +++ b/proxy.py @@ -8,15 +8,16 @@ session = requests.Session() @app.route('/', defaults={'path': ''}, methods=['GET']) @app.route('/', 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('/', 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)