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