地震速報を取得したいのですが、<br/>など、邪魔なものが入ってしまうので、それを\nに置き換えて
改行したいのですがエラーが起きました
python
1import requests 2from urllib.request import urlopen 3from bs4 import BeautifulSoup 4 5hiraku = urlopen("http://www.jma.go.jp/jp/quake/") 6hiraita = BeautifulSoup(hiraku, "lxml") 7nuku = hiraita.findAll("table",{"class":"textframe"})[0] 8finish = nuku.findAll("td") 9finish = finish.replace("<br/>", "\n") 10print(finish)
エラーコード
Traceback (most recent call last): File "hogegege.py", line 9, in <module> finish = finish.replace("<br/>", "\n") File "/Users/zen/anaconda3/lib/python3.6/site-packages/bs4/element.py", line 1807, in __getattr__ "ResultSet object has no attribute '%s'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?" % key AttributeError: ResultSet object has no attribute 'replace'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?
回答よろしくお願いします
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/02 07:20
2017/12/02 07:25
2017/12/02 07:27
2017/12/02 07:42
2017/12/02 07:54