这里使用的是xpath这个第三方python库
使用 from lxml import etree 导入
使用:
select = etree.HTML(html)
content = select.xpath()
for each in content:
print each
一个简单的demo:
from lxml import etreehtml = '''Title xxxx'''select = etree.HTML(html)content = select.xpath("//body/input[@id='name1']/@href")for each in content: print eachprint "end"