Loading

【Day3】5.Python中的lxml模块

import lxml.etree as le

with open('edu.html','r',encoding='utf-8') as f:
    html = f.read()
    html_x = le.HTML(html)
    a_x_s = html_x.xpath("//div[@class='nav_com']/ul/li/a/text()")
    for a in a_x_s:
        print(a)
posted @ 2019-11-20 13:20  5572  阅读(182)  评论(0编辑  收藏  举报