Created
November 3, 2012 15:33
-
-
Save Foxboron/4007664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from bs4 import BeautifulSoup | |
import urllib | |
app = Flask(__name__) | |
def bs4_slice(web_source): | |
soup = BeautifulSoup(web_source) | |
soup.body.find(id="header").decompose() | |
soup.body.find(id="footer").decompose() | |
for i in soup.body("img"): | |
i["src"] = "https://docs.google.com/document/" + i["src"] | |
return soup.prettify() | |
@app.route('/') | |
def index_page(): | |
webpage = urllib.urlopen("https://docs.google.com/document/pub?id=1SGcfQz13ce4FfB-QHKF3WLwxHoCRGBouuvZn-3aoX0k").read() | |
webpage = bs4_slice(web_source=webpage) | |
return webpage | |
if __name__ == '__main__': | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment