Some fixes for generating snapshots against the local host.
This commit is contained in:
parent
da29da5c66
commit
3c3cca1140
2 changed files with 8 additions and 6 deletions
|
@ -7,6 +7,7 @@ MarkupSafe==0.18
|
||||||
PyMySQL==0.5
|
PyMySQL==0.5
|
||||||
Werkzeug==0.9.4
|
Werkzeug==0.9.4
|
||||||
argparse==1.2.1
|
argparse==1.2.1
|
||||||
|
beautifulsoup4==4.3.2
|
||||||
blinker==1.3
|
blinker==1.3
|
||||||
boto==2.13.3
|
boto==2.13.3
|
||||||
distribute==0.6.34
|
distribute==0.6.34
|
||||||
|
|
|
@ -2,15 +2,16 @@ import subprocess
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import codecs
|
||||||
|
|
||||||
from BeautifulSoup import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
BASE_URL = 'http://localhost:5000/'
|
BASE_URL = 'https://localhost/'
|
||||||
OUTPUT_PATH = '../static/snapshots/'
|
OUTPUT_PATH = '../static/snapshots/'
|
||||||
|
|
||||||
URLS = [
|
URLS = [
|
||||||
|
@ -26,8 +27,8 @@ for url in URLS:
|
||||||
|
|
||||||
logger.info('Snapshotting url: %s -> %s' % (final_url, to_write))
|
logger.info('Snapshotting url: %s -> %s' % (final_url, to_write))
|
||||||
|
|
||||||
out_html = subprocess.check_output(['phantomjs', 'phantomjs-runner.js',
|
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
|
||||||
final_url])
|
'phantomjs-runner.js', final_url])
|
||||||
|
|
||||||
# Remove script tags
|
# Remove script tags
|
||||||
soup = BeautifulSoup(out_html)
|
soup = BeautifulSoup(out_html)
|
||||||
|
@ -40,5 +41,5 @@ for url in URLS:
|
||||||
if not os.path.exists(to_write_dir):
|
if not os.path.exists(to_write_dir):
|
||||||
os.makedirs(to_write_dir)
|
os.makedirs(to_write_dir)
|
||||||
|
|
||||||
with open(to_write, 'w') as output_file:
|
with codecs.open(to_write, 'w', 'utf-8') as output_file:
|
||||||
output_file.write(soup.prettify())
|
output_file.write(soup.prettify())
|
||||||
|
|
Reference in a new issue