I am trying to extract the following:
<td class="indent">Interest Income on Fed. Funds</td>
<td class="">-</td>
with this
interest=a.findAll("td",{'class':[''|'indent']},limit=6)
However, it returns
TypeError: unsupported operand type(s) for |: 'str' and 'str'
How could I find empty class OR class_='indent'?
Try this:
interest = a.findAll("td", {'class': [None, 'indent']}, limit=6)
,
separator not with |
) None
Another option as well for 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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.