我试着获取zabbix主页的内容,在那里有一个叫做Last20Issues的部分。你知道吗
import re
some_page=session.get(url,headers=header).content
soup=BeautifulSoup(some_page,'lxml')
print soup.findAll('td',{'class':'average-bg'})
soup is as following
<td><span class='\"link-action\"' data-menu-popup='\"{"type":"host","hostid":"10457","showGraphs":true,"showScreens":true,"showTriggers":true,"hasGoTo":true,"scripts":[{"name":"Detect' operating="" system","scriptid":"3","confirmation":""},{"name":"ping","scriptid":"1","confirmation":""},{"name":"traceroute","scriptid":"2","confirmation":""}]}\"="">ELK211<\/span><\/td><td class='\"average-bg\"'><span #00aa00">ok<\\\="" #dc0000">problem<\\\="" "",="" "max-width:="" '<div><table="" 00:15:36<\\\="" 01:40:36<\\\="" 01:44:36<\\\="" 01:51:36<\\\="" 04:07:36<\\\="" 06:56:36<\\\="" 08:02:36<\\\="" 08:45:36<\\\="" 09:15:36<\\\="" 09:58:36<\\\="" 10:11:36<\\\="" 10d="" 10h<\\\="" 11:59:36<\\\="" 11h="" 11h<\\\="" 12:39:36<\\\="" 12d="" 12h="" 12h<\\\="" 12m<\\\="" 13:37:36<\\\="" 13h<\\\="" 14h="" 15m<\\\="" 16d="" 16m<\\\="" 17:58:36<\\\="" 17h<\\\="" 17m<\\\="" 18d="" 19d="" 19h="" 19m<\\\="" 1h<\\\="" 20d="" 21:30:36<\\\="" 22:18:36<\\\="" 22:49:36<\\\="" 22h="" 22h<\\\="" 23:58:36<\\\="" 23:58:37<\\\="" 23h="" 25m<\\\="" 26m<\\\="" 2d="" 2h<\\\="" 30m="" 32m<\\\="" 39s<\\\="" 3h="" 3h<\\\="" 40m<\\\="" 47m<\\\="" 4h<\\\="" 4m<\\\="" 500px");\"="" 56m<\\\="" 57m<\\\="" 58m<\\\="" 59m="" 59s<\\\="" 6h="" 6m<\\\="" 7h<\\\="" 8m<\\\="" 9h<\\\="" 9m<\\\="" class='\"link-action\"' false,="" href=""zabbix.php?action=acknowledge.edit&eventids[]=2174204&backurl=zabbix.php%3Faction%3Ddashboard.view">No<\\\/a><\\\/td><\\\/tr><\\\/tbody><\\\/table><\\\/div>'," id='"t5947401f69c53"><thead><tr><th>Time<\\\/th><th>Status<\\\/th><th>Duration<\\\/th><th>Age<\\\/th><th>Ack<\\\/th><\\\/tr><\\\/thead><tbody><tr><td>2017-06-18' onclick='\"hintBox.showStaticHint(event,' onmouseover='\"hintBox.HintWraper(event,' red"="" span><\\\="" style='"color:' td><td><a="" td><td><span="" td><td>11d="" td><td>12d="" td><td>1d="" td><td>1h="" td><td>1m="" td><td>21h="" td><td>27d="" td><td>28d="" td><td>29d="" td><td>2h="" td><td>2m="" td><td>3d="" td><td>3h="" td><td>48m<\\\="" td><td>4m<\\\="" td><td>6h="" td><td>7d="" td><td>7m<\\\="" td><td>8h="" td><td>9h="" this,="">Free disk space is less than 10% on volume \/data<\/span><\/td>
我注意到这个类看起来像<td class='\"average-bg\"'>
,所以td中有两个(\”),BS无法识别它。我试图删除\“,这似乎是工作,但整个网页包含了这样的字符很多。替换它们会导致其他一些问题。
最后,我没有得到答案,而是得到了<\/td>
你知道我怎样才能得到像'<td>',</td>,
这样的格式并得到我想要的内容吗。实际上,我只需要“卷/数据的可用磁盘空间少于10%”和“ELK211”。
我试着用html.parser语法分析器,但都是一样的。你知道吗
双引号是类名的一部分。按以下方式修改代码:
或者
相关问题 更多 >
编程相关推荐