2
我对这一切都很陌生,并且很难在使用BeautifulSoup的任何标签之外获取特定文本。使用Beautifulsoup获取文本外侧标签
这里是我的代码:
from bs4 import BeautifulSoup
soup = BeautifulSoup('''
<li id="SalesRank" style="list-style : none">
<b>Sellers Rank:</b>
#81 in Fun
(<a href="http://www.google.com">See Top 100</a>)
</li>
''')
theRank = soup.find('li', attrs={'id':'SalesRank'}).find('b', text="Sellers Rank:")
print theRank.find_next_sibling().text.strip()
我试图让#81 in Fun
什么输出你的代码给你,什么是错呢? – PurpleVermont