
# -- coding: utf-8 --
from bs4 import BeautifulSoup
html='''<dict>
<key>LogType</key>
<string>Default</string>
<key>Message</key>
<string>测试场景:订餐提交页面</string>
<string>Loop in : 2 durTime:0266s</string>
<key>Timestamp</key>
<date>2014-06-06T12:16:24Z</date>
<key>Type</key>
<integer>1</integer>
</dict>'''
soup= BeautifulSoup(html)
trs=soupfindAll("string")
length=len(trs)
arr=[]
for i in range(length):
print trs[i]contents
需要安装BeautifulSoup,代码很容易懂的!
claimtext = rootgetElementsByTagName("claim-text")
for i in claimtext[0]childNodes:
print inodeName #你自己看哈 这里的 inodeName 有俩个类型 br #text ,所以取的时候加个类型判断吧
if inodeName == '#text':
print inodeValue
这玩意这么不好使 要不是 试试 beautifulsoup 这个html 解析标签 效果应该 嘎嘎的
以上就是关于如何获取href标签中的内容 python全部的内容,包括:如何获取href标签中的内容 python、python解析xml文件如何读取所有<br />标签的内容、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)