Skip to content

Instantly share code, notes, and snippets.

@Foxboron
Created November 3, 2012 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Foxboron/4007664 to your computer and use it in GitHub Desktop.
Save Foxboron/4007664 to your computer and use it in GitHub Desktop.
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