作者stanleychao ()
看板Python
標題[閒聊] 初學網路爬蟲beautifulsoup
時間Wed Oct 31 23:45:34 2018
大家好,初學網路爬蟲,先以爬mlb網站為題,不過在用beautifulsoup時遇到了問題
以下為beautifulsoup解析的片段,不過想要擷取(0:0,0:0..........)遇到困難,因
為竟然沒被屬性包起來,想請這要怎麼擷取呢?
[<p class="result"><span class="bold">Final result </span><strong>4:0</strong>
(0:0, 0:0, 0:0, 4:0, 0:0, 0:0, 0:0, 0:0, X:0)</p>]
感謝囉
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 27.246.30.83
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1541000737.A.D69.html
推 toy9986619: 試看看p node的text11/01 00:57
推 vi000246: text應該會抓到包含span跟strong裡的東西11/01 01:09
→ vi000246: 用正規表達式硬幹吧 或是抓兩個圓括號裡的內容11/01 01:10
感謝 順便更新一下
m = re.search(r”\([A-Za-z0-9:,]+\]”)
※ 編輯: stanleychao (39.10.222.48), 11/01/2018 11:00:56