0
我有以下html
,我想獲得文本<b>Name in Thai</b>
之後是: this is what I want
BeautifulSoup html標記後得到的文本
content = """
<html><body><b>Name of Bangkok Bus station:</b>
<span itemprop="name">Victory Monument</span>
<meta content="http://www.transitbangkok.com/stations/Bangkok%20Bus/Victory%20Monument" itemprop="url"/>
<meta content="http://www.transitbangkok.com/stations/Bangkok%20Bus/Victory%20Monument" itemprop="map"/>
<br/><b>Name in Thai</b>: this is what i want<br/>
</body></html>
"""
我想這如下
soup = BeautifulSoup(content, "lxml")
soup.find('b').next_sibling
使用
next_sibling
解決方案
但是,我得到了\n
作爲輸出。有沒有辦法讓特定標籤後的文本(解釋會很棒!)?
啊,明白了!感謝Vallentin非常明確的解釋。 – titipata
不客氣!隨時將答案標記爲已接受。 :) – Vallentin
當然,我必須等待3分鐘:) – titipata