コード例 #1
0
ファイル: test_html_rewriter.py プロジェクト: mirrorweb/pywb
def parse(data,
          head_insert=None,
          urlrewriter=urlrewriter,
          parse_comments=False,
          js_proxy=False):

    if js_proxy:
        js_rewriter_class = JSWombatProxyRewriter
    else:
        js_rewriter_class = None

    parser = HTMLRewriter(urlrewriter,
                          head_insert=head_insert,
                          url=ORIGINAL_URL,
                          js_rewriter_class=js_rewriter_class,
                          parse_comments=parse_comments)

    if js_proxy:
        parser.js_rewriter.first_buff = '{ '
        parser.js_rewriter.last_buff = ' }'

    if six.PY2 and isinstance(data, six.text_type):
        data = data.encode('utf-8')

    result = parser.rewrite(data) + parser.close()

    if six.PY2:
        # decode only for printing
        result = result.decode('utf-8')

    print(result)
コード例 #2
0
ファイル: test_html_rewriter.py プロジェクト: ikreymer/pywb
def parse(data, head_insert=None, urlrewriter=urlrewriter, parse_comments=False,
          js_proxy=False):

    if js_proxy:
        js_rewriter_class = JSWombatProxyRewriter
    else:
        js_rewriter_class = None

    parser = HTMLRewriter(urlrewriter, head_insert=head_insert,
                          url=ORIGINAL_URL,
                          js_rewriter_class=js_rewriter_class,
                          parse_comments=parse_comments)

    if js_proxy:
        parser.js_rewriter.first_buff = '{ '
        parser.js_rewriter.last_buff = ' }'

    if six.PY2 and isinstance(data, six.text_type):
        data = data.encode('utf-8')

    result = parser.rewrite(data) + parser.close()

    if six.PY2:
        # decode only for printing
        result = result.decode('utf-8')

    print(result)
コード例 #3
0
ファイル: test_html_rewriter.py プロジェクト: peval/pywb
def parse(data, head_insert=None, urlrewriter=urlrewriter):
    parser = HTMLRewriter(urlrewriter, head_insert = head_insert, url = ORIGINAL_URL)

    if isinstance(data, unicode):
        data = data.encode('utf-8')
        #data = urllib.quote(data, ':" =/-\\<>')

    result = parser.rewrite(data) + parser.close()
    # decode only for printing
    print result.decode('utf-8')
コード例 #4
0
def parse(data, head_insert=None, urlrewriter=urlrewriter):
    parser = HTMLRewriter(urlrewriter, head_insert=head_insert)

    if isinstance(data, unicode):
        data = data.encode('utf-8')
        #data = urllib.quote(data, ':" =/-\\<>')

    result = parser.rewrite(data) + parser.close()
    # decode only for printing
    print result.decode('utf-8')
コード例 #5
0
ファイル: test_html_rewriter.py プロジェクト: eriknstr/pywb
def parse(data, head_insert=None, urlrewriter=urlrewriter, parse_comments=False):
    parser = HTMLRewriter(urlrewriter, head_insert=head_insert, url=ORIGINAL_URL, parse_comments=parse_comments)

    if six.PY2 and isinstance(data, six.text_type):
        data = data.encode("utf-8")

    result = parser.rewrite(data) + parser.close()

    if six.PY2:
        # decode only for printing
        result = result.decode("utf-8")

    print(result)
コード例 #6
0
def parse(data,
          head_insert=None,
          urlrewriter=urlrewriter,
          parse_comments=False):
    parser = HTMLRewriter(urlrewriter,
                          head_insert=head_insert,
                          url=ORIGINAL_URL,
                          parse_comments=parse_comments)

    if six.PY2 and isinstance(data, six.text_type):
        data = data.encode('utf-8')

    result = parser.rewrite(data) + parser.close()

    if six.PY2:
        # decode only for printing
        result = result.decode('utf-8')

    print(result)
コード例 #7
0
ファイル: test_html_rewriter.py プロジェクト: tilgovi/pywb
def parse(data, head_insert=None, urlrewriter=urlrewriter):
    parser = HTMLRewriter(urlrewriter, head_insert = head_insert)
    #data = data.decode('utf-8')
    result = parser.rewrite(data) + parser.close()
    # decode only for printing
    print result.decode('utf-8')