|
20 | 20 | from urlparse import urlparse, urlunsplit, urljoin
|
21 | 21 | from urllib import quote
|
22 | 22 |
|
23 |
| -re_css_url = re.compile('(url\(.*?\))') |
| 23 | +re_css_url = re.compile(r'(url\(.*?\))') |
24 | 24 | webpage2html_cache = {}
|
25 | 25 |
|
26 | 26 |
|
@@ -256,6 +256,8 @@ def generate(index, verbose=True, comment=True, keep_script=False, prettify=Fals
|
256 | 256 | code = soup.new_tag('script', type=new_type)
|
257 | 257 | code['data-src'] = js['src']
|
258 | 258 | js_str, _ = get(index, relpath=js['src'], verbose=verbose)
|
| 259 | + if type(js_str) == bytes: |
| 260 | + js_str = js_str.decode('utf-8') |
259 | 261 | try:
|
260 | 262 | if js_str.find('</script>') > -1:
|
261 | 263 | code['src'] = 'data:text/javascript;base64,' + base64.b64encode(js_str)
|
@@ -359,7 +361,7 @@ def main():
|
359 | 361 | kwargs = {}
|
360 | 362 | parser = argparse.ArgumentParser()
|
361 | 363 | 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") |
363 | 365 | parser.add_argument('-k', '--insecure', action='store_true', help="ignore the certificate")
|
364 | 366 | parser.add_argument('-o', '--output', help="save output to")
|
365 | 367 | parser.add_argument('--errorpage', action='store_true', help="crawl an error page")
|
|
0 commit comments