python - 正則如何提取標(biāo)題
問(wèn)題描述
通過(guò)以下代碼提取標(biāo)題:Delivery from £3.99 at Yours Clothing請(qǐng)問(wèn)正則怎么書(shū)寫(xiě)呀?跪求高手指點(diǎn),謝謝!
<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://www.piao2010.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='http://www.piao2010.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='http://www.piao2010.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>## 標(biāo)題文字 ##
問(wèn)題解答
回答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>>>
相關(guān)文章:
1. mysql - sql 左連接結(jié)果union右連接結(jié)果,導(dǎo)致重復(fù)性計(jì)算怎么解決?2. 怎么能做出標(biāo)簽切換頁(yè)的效果,(文字內(nèi)容隨動(dòng))3. mysql 遠(yuǎn)程連接出錯(cuò)10060,我已經(jīng)設(shè)置了任意主機(jī)了。。。4. 默認(rèn)輸出類型為json,如何輸出html5. 數(shù)組排序,并把排序后的值存入到新數(shù)組中6. php多任務(wù)倒計(jì)時(shí)求助7. mysql的主從復(fù)制、讀寫(xiě)分離,關(guān)于從的問(wèn)題8. mysql怎么表示兩個(gè)字段的差9. PHP訂單派單系統(tǒng)10. MySQL的聯(lián)合查詢[union]有什么實(shí)際的用處
