[問題] bs4 findAll method 後如何提取content?
大家好
我在練習用爬蟲爬yahoo字典的資料
原始碼如下:
import requests
from bs4 import BeautifulSoup
Url = requests.get('http://tw.dictionary.search.yahoo.com/search?p=fat')
TargetHtml = BeautifulSoup(Url.text,"html.parser")
parser = TargetHtml.findAll('span', class_='fc-6th fz-15px')
print (parser.contents)
卻會出現
AttributeError: 'ResultSet' object has no attribute 'contents'
可是我看Stackoverflow 都是這樣提取內文的啊?
要如何正確提取內文呢?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.12.74
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1486276763.A.6D0.html
推
02/05 15:43, , 1F
02/05 15:43, 1F
→
02/05 15:44, , 2F
02/05 15:44, 2F
→
02/05 15:44, , 3F
02/05 15:44, 3F
推
02/05 15:47, , 4F
02/05 15:47, 4F
→
02/05 15:48, , 5F
02/05 15:48, 5F
Python 近期熱門文章
PTT數位生活區 即時熱門文章