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://www.aoyou183.cn/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.aoyou183.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://www.aoyou183.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. javascript - 在 vue里面用import引入js文件,結果為undefined2. html - 爬蟲時出現“DNS lookup failed”,打開網頁卻沒問題,這是什么情況?3. 求教一個mysql建表分組索引問題4. 小程序怎么加外鏈,語句怎么寫!求救新手,開文檔沒發現5. html5 - input type=’file’ 上傳獲取的fileList對象怎么存儲于瀏覽器?6. 求救一下,用新版的phpstudy,數據庫過段時間會消失是什么情況?7. python沒入門,請教一個問題8. php如何獲取訪問者路由器的mac地址9. node.js - 用nodejs 的node-xlsx模塊去讀取excel中的數據,可是讀取出來的日期是數字,請問該如何讀取日期呢?10. javascript - 我的站點貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?
