#!/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)

 

相关文章:

  • 2022-01-01
  • 2022-03-02
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2021-08-17
  • 2021-11-28
猜你喜欢
  • 2021-08-17
  • 2021-08-17
  • 2022-01-14
  • 2021-12-19
  • 2022-12-23
  • 2021-12-07
相关资源
相似解决方案