3
我正在使用beautifulsoup網頁抓取。該網頁有以下來源:大量的空白beautifulsoup
<td>\n<a href="http://aaa.com">Charles</a>\r\n (hello)\r\n </td>,
<td>\n<a href="http://bbb.com">Diane</a>\r\n (hi)\r\n </td>,
<td>\n<a href="http://ccc.com">Kevin</a>\r\n (how are you doing)\r\n </td>
我用下面的代碼來打印兩個值。他們工作得很好。
for item in soup.find_all("td"):
print item.find('a').text
print item.find('a').next_sibling
問題是當我將輸出保存在csv文件中,第二列沒有值時。這似乎是因爲有很多空白。任何建議?提前致謝。
作品!感謝您的解決方案! – kevin