【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)

猜你喜欢

转载自www.cnblogs.com/zsczsc/p/11897078.html