[英]BeautifulSoup FindAll with OR and Empty Class
我正在嘗試提取以下內容:
<td class="indent">Interest Income on Fed. Funds</td>
<td class="">-</td>
有了這個
interest=a.findAll("td",{'class':[''|'indent']},limit=6)
但是,它返回
TypeError:|:'str'和'str'不支持的操作數類型
如何找到空類或class _ ='indent'?
嘗試這個:
interest = a.findAll("td", {'class': [None, 'indent']}, limit=6)
,
分隔符不使用|
) None
空類 bs4的另一個選擇:
def empty_or_indent(css_class):
return css_class is None or css_class is 'indent'
a.find_all('td', class_=empty_or_indent, limit=6)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.