python - 正则如何提取标题
问题描述
通过以下代码提取标题:Delivery from £3.99 at Yours Clothing请问正则怎么书写呀?跪求高手指点,谢谢!
<article data-offer-type='deal' class='offer-module js-offer-module list-module deal
merch-offer ' data-merchant='Yours Clothing' data-revision='2' data-variant='0' data-tab-group='online'><p class='offer-border'><a href='https://www.haobala.com/wenda/10332.html#' data-offerid='[4611854]'><i src-src='https://static-cdn.voucherco.co.uk/v10/images/_generated-sprites/offer-module-sprite@1x-cb-f3f7588d80d53be535315092f1d3d9ad.png' src-retina-src='https://static-cdn.vouchercodes.co.uk/v10/images/_generated-sprites/offer-module-sprite@2x-cb-659802c69b2fbdde72289424326e4eb4.png'></i> </a><p class='left-col'> <a href='https://www.haobala.com/out/offer/4611854/e7132f242406a3ef32a2b03703e9796951dff0cd/?ps=9&pageViewID=14903446907945303647157958d4daf24d1f5971796&wotst=ve0317_nove&mi=yoursclothing.co.uk&ppc=&tl=deal-offerimg&opi=mpx&inv=online&scc=0&sss=merchant&spn=%2Fyoursclothing.co.uk&spl=desktop&spv=14903439557945303648611658d4d813a3574281781&stv=ve0317_nove&sui=null&sli=0'><imgsrc='https://static-cdn.voucherco.co.uk/v10/images/merchant/logo/128px/1142_140311175132.png' alt='Yours Clothing'/><strong class='offer-type label-deal'>deal</strong> </a></p><p class='offer-details'> <p class='header-wrapper'><h3 class='tp-offertitle js-offer-title'><a href='https://www.haobala.com/out/offer/4611854/e7132f242406a3ef32a2b03703e9796951dff0cd/?ps=9&pageViewID=14903446907945303647157958d4daf24d1f5971796&wotst=ve0317_nove&mi=yoursclothing.co.uk&ppc=&tl=deal-title&opi=mpx&inv=online&scc=0&sss=merchant&spn=%2Fyoursclothing.co.uk&spl=desktop&spv=14903439557945303648611658d4d813a3574281781&stv=ve0317_nove&sui=null&sli=0' class='js-click-reveal'> Delivery <strong>from £3.99</strong> at Yours Clothing</a> </h3>## 标题文字 ##
问题解答
回答1:>>> str_split = re.findall(r’js-click-reveal'>n([sS]*?)<strong>([sS]*?)</strong>([sS]*?)n’, html)[0]>>> print str_split[0].lstrip() + str_split[1] + str_split[2]Delivery from £3.99 at Yours Clothing>>>
相关文章:
1. mac里的docker如何命令行开启呢?2. docker start -a dockername 老是卡住,什么情况?3. docker-compose 为何找不到配置文件?4. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?5. docker pull 错误?6. macos - mac下docker如何设置代理7. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!8. mac连接阿里云docker集群,已经卡了2天了,求问?9. docker镜像无法删除,请求解决办法。10. node.js - 来帮我捋一下node中fs模块watch实现原理