コード例 #1
0
ファイル: lx_simple.py プロジェクト: jeffreywinn/jabbapylib
def demo4():
    text = """
<html>
    <table>
        <tr><td>http://google.ca</td></tr>
        <tr><td>http://reddit.com</td></tr>
    </table>
</html>
"""
    doc = lx.to_doc(text)
    doc = lx.autolink(doc)
    print lx.prettify(doc)
コード例 #2
0
ファイル: test_lx.py プロジェクト: ThePenguin1140/jabbapylib
def test_prettify():
    doc = lx.to_doc(ex.UGLY, parser=scraper.LXML_HTML)
    #
    nice = lx.prettify(doc, method=scraper.LXML_HTML)
    assert '</h1>' in nice and '</html>' in nice
    #
#    nice = lx.prettify(doc, method=scraper.HTML5PARSER)    # missing
    #
    nice = lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
    assert '</h1>' in nice and '</html>' in nice
    #
    nice = lx.prettify(doc, method=scraper.TIDY)
    assert '</h1>' in nice and '</html>' in nice
    #
    nice = lx.prettify(doc, method=None)
    assert nice is None
コード例 #3
0
def test_prettify():
    doc = lx.to_doc(ex.UGLY, parser=scraper.LXML_HTML)
    #
    nice = lx.prettify(doc, method=scraper.LXML_HTML)
    assert '</h1>' in nice and '</html>' in nice
    #
    #    nice = lx.prettify(doc, method=scraper.HTML5PARSER)    # missing
    #
    nice = lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
    assert '</h1>' in nice and '</html>' in nice
    #
    nice = lx.prettify(doc, method=scraper.TIDY)
    assert '</h1>' in nice and '</html>' in nice
    #
    nice = lx.prettify(doc, method=None)
    assert nice is None
コード例 #4
0
ファイル: lx_simple.py プロジェクト: jeffreywinn/jabbapylib
def demo3():
    html = """<html>
  <head>
    <script type="text/javascript" src="stuff.js"></script>
    <link rel="alternate" type="text/rss" src="some-rss">
    <style>
        body {background-image: url(javascript:do_something)};
        div {color: expression(something)};
    </style>
  </head>
  <body onload="some_function()">
     Hello World!
  </body>
 </html>"""
    doc = lx.to_doc(html)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
コード例 #5
0
def demo1():
    text = "<table><td>foo"
    parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("lxml"), namespaceHTMLElements=False)
    doc = parser.parse(text)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
コード例 #6
0
def demo3():
    doc = lx.to_doc(text, parser=scraper.BEAUTIFULSOUP)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
コード例 #7
0
def demo2():
    doc = lx.to_doc(text, parser=scraper.HTML5PARSER)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
コード例 #8
0
def demo1():
    doc = lx.to_doc(text)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
コード例 #9
0
ファイル: lx_html5lib.py プロジェクト: the7day/jabbapylib
def demo1():
    text = "<table><td>foo"
    parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("lxml"),
                                 namespaceHTMLElements=False)
    doc = parser.parse(text)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
コード例 #10
0
def demo3():
    doc = lx.to_doc(text, parser=scraper.BEAUTIFULSOUP)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
コード例 #11
0
def demo2():
    doc = lx.to_doc(text, parser=scraper.HTML5PARSER)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)
コード例 #12
0
def demo1():
    doc = lx.to_doc(text)
    print lx.prettify(doc, method=scraper.BEAUTIFULSOUP)