关于正则表达式参考正则表达式
python可以很方便地抓取网页并过滤网页的内容,那么,如何从如下的网页中提取csdn文章的标题“《unix网络编程(卷1)源代码的使用方法》”。
<script type="text/ecmascript">
window.quickReplyflag = true;
</script>
<div id="article_details" class="details">
<div class="article_title">
<span class="ico ico_type_Original"></span>
<h1>
<span class="link_title"><a href="/u013074465/article/details/44280335">
《unix网络编程(卷1)》源代码的使用方法
</a></span>
</h1>
</div>
如下是核心代码,使用正则表达式实现:
html2 = opener.open(page).re