#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time :2021/9/26 14:29 @Author :维斯 @File :test.py @Version :1.0 @Function: """ from lxml import etree if __name__ == '__main__': url = 'http://www.baidu.com/' parse_result = etree.parse(url, parser=etree.HTMLParser()) result = parse_result.xpath('//a//@href') # 获取所有a标签的href属性值(返回一个list列表) print(result)