不要なタグを削除するため、.extract()で処理を行おうとしていますが、
なぜ、 'NoneType' object is not callable になってしまうのか、
また、解決方法が分からない状態です。
どなたかアドバイスください。
python
1import requests 2from bs4 import BeautifulSoup 3 4url = "https://scraping-for-beginner.herokuapp.com/ranking/" 5res = requests.get(url) 6soup = BeautifulSoup(res.text, "html.parser") 7 8spots = soup.find_all("div", attrs={"class": "u_areaListRankingBox"}) 9spot = spots[0] 10 11spot_name = spot.find("div", attrs={"class": "u_title"}) 12 13# '\n1観光地 1\n' \n1を削除する処理 14spot_name.find("span", attrs={"class": "badge"}).extracct() # ここでエラー
お二方からスペルミスとの指摘があって、それは正しいのですが、スペルミスだけが原因だと、
'NoneType' object is not callable
というエラーにはなりません。
エラーメッセージの全文を載せてもらえれば、もう少し何かわかるかもしれません。

Google Colaboratory上で実行しており、
spot_name.find("span", attrs={"class": "badge"}).extracct()より前のセルを実行していなかったために発生していたようです。

回答3件
あなたの回答
tips
プレビュー