尝试使用 BeautifulSoup (它是一个“标签”对象)获取此类 html 片段的内容。
<span class="font5"> arrives at this calculation from the Torah’s report that the deluge (rains) began on the 17<sup>th</sup> day of the second month </span>
我试过:
soup.contents.find_all('span')
soup.find_all('span')
soup.find_all(re.compile("font[0-9]+"))
soup.string
soup.child
而且这些似乎都不起作用。我能做什么?
请您参考如下方法:
soup.find_all('span')确实有效;返回所有 span标签。
如果你想得到span用 font<N> 标记类,将模式指定为关键字参数 class_ :
soup.find_all('span', class_=re.compile('font[0-9]+'))
