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


from lxml import etree


def fetch_text(html):
    html = etree.HTML(html)
    result = html.xpath("//text()")
    return result


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


if __name__ == '__main__':
    test()
