Python beautifulsoup4:如何检索特定标记的类名列表
我从beautifulsoup4得到:Python beautifulsoup4:如何检索特定标记的类名列表,python,python-3.x,beautifulsoup,Python,Python 3.x,Beautifulsoup,我从beautifulsoup4得到: <tr class="Details"> <td class=" s-12-to-15 ">ABC</td> <td class="s-15-to-18 ">DEF</td> <td class=" s-18-to-21 ">GHI</td></tr> 我查阅了bf4文档和几个关于检索类名的堆栈问题,但没有成功。我无法找到检索这些类的方法。(我知道我可以解析字
<tr class="Details"> <td class=" s-12-to-15 ">ABC</td> <td class="s-15-to-18 ">DEF</td> <td class=" s-18-to-21 ">GHI</td></tr>
我查阅了bf4文档和几个关于检索类名的堆栈问题,但没有成功。我无法找到检索这些类的方法。(我知道我可以解析字符串以获得结果,但我有兴趣了解bf4)。我尝试了20多种组合,使用var.find('td')和var.('tr',{class'[])var.('td.class')等@depperm我猜你否决了我。多亏了elrull,我找到了.join(s['class'])我正在寻找。我想知道在bf4文档中哪里可以找到它:python35语法:dayPrecipit中的s.find_all('td'):print(''.join(s['class']).strip(),s.text)the
'.join(listToConvert)
将列表转换为字符串变量['class']
为查找文档的人发送类名:
s-12-to-15 ABC
s-15-to-18 DEF
s-18-to-21 GHI
for s in soup.find_all('td'):
print ''.join(s['class']).strip(), s.text