How to use the selectolax.parser.Node function in selectolax

To help you get started, we’ve selected a few selectolax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rushter / selectolax / tests / test_parser.py View on Github external
def test_nodes():
    html = (
        '<div><p id="p1"></p><p id="p2"></p><p id="p3"><a>link</a></p>'
        '<p id="p4"></p><p id="p5">text</p><p id="p6"></p></div>'
    )
    htmlp = HTMLParser(html)

    assert isinstance(htmlp.root, Node)
    assert isinstance(htmlp.body, Node)
    html_output = htmlp.html
    assert len(html_output) &gt;= len(html)
    assert SequenceMatcher(None, html, html_output).ratio() &gt; 0.8
github rushter / selectolax / tests / test_parser.py View on Github external
def test_nodes():
    html = (
        '<div><p id="p1"></p><p id="p2"></p><p id="p3"><a>link</a></p>'
        '<p id="p4"></p><p id="p5">text</p><p id="p6"></p></div>'
    )
    htmlp = HTMLParser(html)

    assert isinstance(htmlp.root, Node)
    assert isinstance(htmlp.body, Node)
    html_output = htmlp.html
    assert len(html_output) &gt;= len(html)
    assert SequenceMatcher(None, html, html_output).ratio() &gt; 0.8

selectolax

Fast HTML5 parser with CSS selectors.

MIT
Latest version published 15 days ago

Package Health Score

82 / 100
Full package analysis

Similar packages