作者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://webptt.com/cn.aspx?n=bbs/Python/M.1541000737.A.D69.html
1F:推 toy9986619: 试看看p node的text11/01 00:57
2F:推 vi000246: text应该会抓到包含span跟strong里的东西11/01 01:09
3F:→ vi000246: 用正规表达式硬干吧 或是抓两个圆括号里的内容11/01 01:10
感谢 顺便更新一下
m = re.search(r”\([A-Za-z0-9:,]+\]”)
※ 编辑: stanleychao (39.10.222.48), 11/01/2018 11:00:56