First pass at the proxy.

This commit is contained in:
Tyler G. Hicks-Wright 2013-12-12 09:11:34 -07:00
commit 43c008917b
3 changed files with 44 additions and 0 deletions

20 Normal file
View File

@ -0,0 +1,20 @@
from bs4 import BeautifulSoup
def macify(html):
soup = BeautifulSoup(html)
for tag in soup(['script', 'link', 'style', 'img', 'noscript']):
for tag in soup(['div', 'span']):
for tag in soup():
for attr in ['style', 'onclick']:
del tag[attr]
return str(soup)
if __name__ == '__main__':
import requests
html = requests.get('').content
html = macify(html)
with open('macified.html', 'w') as fd:

22 Normal file
View File

@ -0,0 +1,22 @@
from macify import macify
import requests
from flask import request, Flask
app = Flask(__name__)
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)
return macify(resp.content), resp.status_code
@app.route('/', defaults={'path': ''}, methods=['POST'])
@app.route('/<path:path>', methods=['POST'])
def post(path):
resp =, data=request.form, allow_redirects=True)
return macify(resp.content), resp.status_code
if __name__ == '__main__':
app.debug = True

requirements.txt Normal file
View File

@ -0,0 +1,2 @@