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)