2024-04-20 12:26:38 发布
网友
所以我有一个html文件,我想检查其中的一些值。 例如:data online=“false”,data channel=“123breakmefree”
所以我想检查“数据在线”是否设置为真或假,以及数据通道中标记的通道。如果频道不是“123breakmefree”。你知道吗
谢谢!你知道吗
注:英语不是我的主要语言,所以我在谷歌上找不到任何关于英语的东西。你知道吗
此代码显示如何加载html字符串、获取标记以及属性:
from bs4 import BeautifulSoup html = '<div id="my-tag" data-online="false" data-channel="123breakmefree">test text</div>' s = BeautifulSoup(html) tag = s.find(id='my-tag') print tag.attrs print tag['data-online'] print tag['data-channel']
此代码显示如何加载html字符串、获取标记以及属性:
相关问题 更多 >
编程相关推荐