More updates to allow for static snapshotting.

This commit is contained in:
yackob03 2013-10-10 23:42:03 -04:00
parent 785995b473
commit da29da5c66
5 changed files with 25 additions and 7 deletions

View file

@ -1,18 +1,30 @@
import subprocess
import urllib
import os
import logging
from BeautifulSoup import BeautifulSoup
BASE_URL = 'http://localhost:5000'
OUTPUT_PATH = 'snapshots/'
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
BASE_URL = 'http://localhost:5000/'
OUTPUT_PATH = '../static/snapshots/'
URLS = [
('/', 'index.html')
'',
'guide/',
'plans/',
'repository/',
]
for url, output in URLS:
for url in URLS:
final_url = BASE_URL + url
to_write = OUTPUT_PATH + url + 'index.html'
logger.info('Snapshotting url: %s -> %s' % (final_url, to_write))
out_html = subprocess.check_output(['phantomjs', 'phantomjs-runner.js',
final_url])
@ -23,7 +35,10 @@ for url, output in URLS:
for item in to_extract:
item.extract()
to_write = OUTPUT_PATH + output
to_write_dir = os.path.dirname(to_write)
if not os.path.exists(to_write_dir):
os.makedirs(to_write_dir)
with open(to_write, 'w') as output_file:
output_file.write(soup.prettify())