你好 :) 玩了一会儿之后,我想出了以下函数,它返回完整的 HTML 标签,而不是简单的倒置 < >"this"< >中的部分
from BeautifulSoup import BeautifulSoup
from urllib2 import urlopen
def get_wotd():
return str((BeautifulSoup(urlopen('http://www.reference.com/wordoftheday'))).findAll('h2'))
print get_wotd()
例如,今天的单词是“nosh”。而不是得到:
[<h2 class="me">nosh</h2>]
我需要输出,简单地说,
nosh
有人知道我怎么能做到这一点吗?