0
similarlist = res.find_all_next("div", class_="result-wrapper")
for item in similarlist:
print(item)
這將返回:BeautifulSoup - 擺脫段的空格/換行符
<div class="result-wrapper">
<div class="row-fluid result-row">
<div class="span6 result-left">
<p>
<a class="tooltipLink warn-cs" data-original-title="Listen" href="..." rel="tooltip"><i class="..."></i></a>
<a class="muted-link" href="/dictionary/german-english/aa-machen">Aa <b>machen</b></a>
</p>
</div>
<div class="span6 result-right row-fluid">
<span class="span9">
<a class="muted-link" href="/dictionary/english-german/do-a-poo">to do a poo</a>, <a class="muted-link" href="/dictionary/english-german/pooh">to pooh</a>
</span>
</div>
</div>
</div>
當我選擇打印item.get_text()
相反,我得到
abgeneigt machen
to disincline
abhängig machen
2137
to predicate
Absenker machen
to layer
所以基本上很多新線我不需要的列表項之間。這是因爲<p>
標籤?我如何擺脫它們?
這隻會從開始和結束,而不是中間刪除空白。 –