Fix some things with the seo snapshots and use the pep8 style guite.

This commit is contained in:
yackob03 2013-11-18 18:42:27 -05:00
parent af4c67d7cb
commit 6355b4a217
3 changed files with 26 additions and 27 deletions

View file

@ -1,27 +1,24 @@
import subprocess
import urllib
import os
import logging
import codecs
from bs4 import BeautifulSoup
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
def renderSnapshot(path):
final_url = 'http://localhost:5000/' + path
logger.info('Snapshotting url: %s -> %s' % (path, final_url))
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
'util/phantomjs-runner.js', final_url])
def render_snapshot(path):
final_url = 'http://localhost:5000/' + path
logger.info('Snapshotting url: %s -> %s' % (path, final_url))
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
'util/phantomjs-runner.js', final_url])
if not out_html or out_html.strip() == 'Not Found':
return None
if not out_html or out_html.strip() == 'Not Found':
return None
# Remove script tags
soup = BeautifulSoup(out_html)
to_extract = soup.findAll('script')
for item in to_extract:
item.extract()
# Remove script tags
soup = BeautifulSoup(out_html.decode('utf8'))
to_extract = soup.findAll('script')
for item in to_extract:
item.extract()
return soup.prettify()
return str(soup)