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='http://m.cgvv.com.cn/wenda/10332.html#' data-offerid='[4611854]'><i src-src='https://static-cdn.voucherco.co.uk/v10/images/_generated-sprites/[email protected]' src-retina-src='https://static-cdn.vouchercodes.co.uk/v10/images/_generated-sprites/[email protected]'></i> </a><p class='left-col'> <a href='http://m.cgvv.com.cn/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='http://m.cgvv.com.cn/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. 數(shù)據(jù)庫 - mysql如何處理數(shù)據(jù)變化中的事務?2. mysql - 怎么生成這個sql表?3. 關于docker下的nginx壓力測試4. java - mongodb分片集群下,count和聚合統(tǒng)計問題5. java - ehcache緩存用的是虛擬機內(nèi)存么?6. javascript - JS如何取對稱范圍的隨機數(shù)?7. docker-machine添加一個已有的docker主機問題8. java - 自己制作一個視頻播放器,遇到問題,用的是內(nèi)置surfaceview類,具體看代碼!9. dockerfile - 我用docker build的時候出現(xiàn)下邊問題 麻煩幫我看一下10. dockerfile - [docker build image失敗- npm install]
