尝试使用美汤(它是一个"tag“对象)来获取这种类型的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
而这些似乎都不起作用。我能做什么?
发布于 2016-10-11 08:14:56
soup.find_all('span')
可以工作;返回所有span
标记。
如果要使用font<N>
类获取span
标记,请将模式指定为关键字参数class_
soup.find_all('span', class_=re.compile('font[0-9]+'))
发布于 2016-10-11 09:21:19
如果以font开头足够独特,还可以使用css选择器查找以font开头的类:
soup.select("span[class^=font]")
发布于 2016-10-11 22:52:09
print ''.join(soup.findAll(text=True))
(回答here)
https://stackoverflow.com/questions/39968593
复制相似问题