bs4.find_all()搜索文档树和css选择器提取解析后的html数据

from bs4 import BeautifulSoup
html = '''
    <html>
        <head>
            <title>Page Title</title>
        </head>
        <body>
            <div class="info" float="left">welcome</div>
            <div class="info" float="right">
                <p class="text">A paragraph</p>
                <span>spider</span>
                <strong><!--this is a comment-->strong</strong>
            </div>
        </body>
    </html>
'''
soup = BeautifulSoup(html, 'html.parser')

 

posted @ 2024-09-28 13:49  松鼠q  阅读(2)  评论(0编辑  收藏  举报