Skip to content

Commit 89591f7

Browse files
author
hbrunopereira
committed
Resolving error to save pages with bootstrap.js
1 parent be3fe0e commit 89591f7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

webpage2html.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from urlparse import urlparse, urlunsplit, urljoin
2121
from urllib import quote
2222

23-
re_css_url = re.compile('(url\(.*?\))')
23+
re_css_url = re.compile(r'(url\(.*?\))')
2424
webpage2html_cache = {}
2525

2626

@@ -256,6 +256,8 @@ def generate(index, verbose=True, comment=True, keep_script=False, prettify=Fals
256256
code = soup.new_tag('script', type=new_type)
257257
code['data-src'] = js['src']
258258
js_str, _ = get(index, relpath=js['src'], verbose=verbose)
259+
if type(js_str) == bytes:
260+
js_str = js_str.decode('utf-8')
259261
try:
260262
if js_str.find('</script>') > -1:
261263
code['src'] = 'data:text/javascript;base64,' + base64.b64encode(js_str)
@@ -359,7 +361,7 @@ def main():
359361
kwargs = {}
360362
parser = argparse.ArgumentParser()
361363
parser.add_argument('-q', '--quite', action='store_true', help="don't show verbose url get log in stderr")
362-
parser.add_argument('-s', '--script', action='store_true', help="keep javascript in the generated html ")
364+
parser.add_argument('-s', '--script', action='store_true', help="keep javascript in the generated html")
363365
parser.add_argument('-k', '--insecure', action='store_true', help="ignore the certificate")
364366
parser.add_argument('-o', '--output', help="save output to")
365367
parser.add_argument('--errorpage', action='store_true', help="crawl an error page")

0 commit comments

Comments
 (0)