[root@yyjk ~/sbin/cmdb]#cat a1.py
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from lxml import etree
aaa='<span plugin-ciinfo class="userInfo" data-position="fixed" userid="1111">aa</span> <span plugin-ciinfo class="userInfo" data-position="fixed" userid="2222">bb</span><br><span plugin-ciinfo class="userInfo" data-position="fixed" userid="3333">cc</span>'
htmlEmt=etree.HTML(aaa)
ccc=htmlEmt.xpath('//span/@userid')
print ccc
[root@yyjk ~/sbin/cmdb]#python a1.py
['1111', '2222', '3333']
根据span标签的userid字段获取信息
最新推荐文章于 2022-01-23 15:44:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)