How to use the buku.import_html function in buku

To help you get started, we’ve selected a few buku 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 jarun / Buku / tests / test_buku.py View on Github external
def test_import_html_and_add_parent():
    from buku import import_html
    from bs4 import BeautifulSoup
    html_text = """<dt><h3>1s</h3>
<dl><p>
</p><dt><a href="http://example.com/"></a>"""
    exp_res = ('http://example.com/', None, ',1s,', None, 0, True, False)
    html_soup = BeautifulSoup(html_text, 'html.parser')
    res = list(import_html(html_soup, True, None))
    assert res[0] == exp_res
</dt></dl></dt>
github jarun / Buku / tests / test_buku.py View on Github external
def test_import_html_and_new_tag():
    from buku import import_html
    from bs4 import BeautifulSoup
    html_text = """<dt><a href="https://github.com/j">GitHub</a>
</dt><dd>comment for the bookmark here"""
    exp_res = (
        'https://github.com/j', 'GitHub', ',tag1,tag2,tag3,',
        'comment for the bookmark here', 0, True, False
    )
    html_soup = BeautifulSoup(html_text, 'html.parser')
    res = list(import_html(html_soup, False, 'tag3'))
    assert res[0] == exp_res
</dd>
github jarun / Buku / tests / test_buku.py View on Github external
"""DT&gt;<a href="https://github.com/j">GitHub</a>
            <dd>comment for the bookmark here""",
            ((
                'https://github.com/j', 'GitHub', ',tag1,tag2,',
                'comment for the bookmark here', 0, True, False
            ),)
        )

    ]
)
def test_import_html(html_text, exp_res):
    """test method."""
    from buku import import_html
    from bs4 import BeautifulSoup
    html_soup = BeautifulSoup(html_text, 'html.parser')
    res = list(import_html(html_soup, False, None))
    for item, exp_item in zip(res, exp_res):
        assert item == exp_item, 'Actual item:\n{}'.format(item)
</dd>