【发布时间】:2016-03-22 01:02:35
【问题描述】:
<meta itemprop="streetAddress" content="4103 Beach Bluff Rd">
我必须获取内容“4103 Beach Bluff Rd”。我正在尝试使用BeautifulSoup 完成此操作,所以,我正在尝试:
soup = BeautifulSoup('<meta itemprop="streetAddress" content="4103 Beach Bluff Rd"> ')
soup.find(itemprop="streetAddress").get_text()
但是我得到一个空字符串作为结果,考虑到当打印汤对象时这可能是有意义的
print soup
我明白了:
<html><head><meta content="4103 Beach Bluff Rd" itemprop="streetAddress"/> </head></html>
显然我想要的数据在'元内容'标签中,我怎样才能得到这个数据?
【问题讨论】:
标签: python html beautifulsoup html-parsing