# -*- coding: UTF-8 -*-
# 作者：zxm2015
# 标题：BeautifulSoup 获取text
# 描述：获取网页的text

from bs4 import BeautifulSoup


def fetch_text(html):
    soup = BeautifulSoup(html, 'lxml')
    return soup.text


def test():
    html = '''
        <html>
            <head>
                <title>这是一个简单的测试页面</title>
            </head>
            <body>
                <p class="item-0">body 元素的内容会显示在浏览器中。</p>
                <p class="item-1">title 元素的内容会显示在浏览器的标题栏中。</p>
            </body>
        </html>
        '''
    text = fetch_text(html)
    print(text)


if __name__ == '__main__':
    test()
