python怎么用正则怎么获取标题
大家讲道理
大家讲道理 2016-11-12 11:06:23
0
3
853
<h3 class="title h1 js-title"> 
<a href="/wenda/2084" target="2084" data-main-tab="/wenda/2084" data-new-tab="php.cn/python-tutorials-351098.html"> $300 Off Phantom 3 Standard </a> 
</h3>
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(1)
阿神

反向思维, 从标签中找到文本很麻烦, 所以我们干脆就把别的标签都干掉

import re
html = u'<h3 class="title h1 js-title"> <a href="/wenda/2084" target="2084" data-main-tab="/wenda/2084" data-new-tab="php.cn/python-tutorials-351098.html"> $300 Off Phantom 3 Standard </a> </h3>'title = re.sub(ur'<.+?>', '', html).strip()print title # $300 Off Phantom 3 Standard


热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!