我做的這個教程 - > http://programminghistorian.org/lessons/intro-to-beautiful-soupBS對象有沒有屬性「分解」
當我運行後續代碼我得到這個錯誤:
AttributeError: 'NoneType' object has no attribute 'decompose'
from bs4 import BeautifulSoup
soup = BeautifulSoup (open("43rd-congress.html"))
final_link = soup.p.a
final_link.decompose()
links = soup.find_all('a')
for link in links:
print(link)
我可以」不明白爲什麼我得到這個錯誤。我不確定soup.p.a是做什麼的。谷歌搜索但沒有出現...
謝謝!這是soup.p.a.造成了這個問題。我不知道這意味着什麼。現在很清楚! –