如何使用正则表达式查找网页中的内容

2025-05-14 06:37:36
推荐回答(1个)
回答1:

这个要看你用什么语言来查找,具体格式我就不说了,比如匹配 

标题

通过正则提取标题内容 采用正则表达式:

/(.+?)<\/title>/</pre>
<p>用PHP实现就是<br></p>
<pre t="code" l="php"><?php<br>    preg_match("/<title>(.+?)<\/title>/",$html,$match);</pre>
<p>请采纳,你的问题太吗模糊了,我只能给你这个答案。</p></p>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
                
            </div>
        </div>

        <div class="wendaright">
            <div class="wdluluerwema">
                <div class="wdxgwttop">相关问答</div>
                <div class="wdxgwtnr">
                                    </div>
                <div class="clear"></div>
            </div>



            <!-- 其他随机问答['id'=>alphaID($like['zid'])] -->
            <div class="wdluluerwema">
                <div class="wdxgwttop">最新问答</div>
                <div class="wdxgwtnr">
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/1435050700934789459.html">无锡住房公积金初始密码是什么</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/1242713872873256859.html">it was the first time in a year that i had seen the night face to face 本句考查了什么</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/1544752551289991947.html">脊灰减毒活疫苗在-17度储存有问题吗</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/431233133904290012.html">深圳市赛格达声进出口有限公司怎么样?</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/526000604478982445.html">腾讯王卡,为什么听歌还是费流量?</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/751787375681951924.html">有没有联想S898t的内外屏</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/199179860.html">劳驾诸位,有知道大连大洋船舶工程有限公司的情况吗?听说是韩国独资企业,待遇如何?有发展前景吗?</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/593649773.html">这是一起交通事故,小轿车与摩托车相撞,地点是红绿灯十字路口,小轿车走主道再前,摩托车在后走超车道,</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/306678310905472644.html">宏城影院今天上影节目表</a></div>
                        </div>
                                            <div class="wdxgwtcont">
                            <div class="wdxgtitle"><a href="https://www.191i.com/index.php/717544645500996285.html">太原市泰利城科技开发建筑工程有限公司招聘信息,太原市泰利城科技开发建筑工程有限公司怎么样?</a></div>
                        </div>
                                    </div>
            </div>


        </div>
        <div class="clear"></div>
        <div class="footer">
            <!-- 移动底部导航 -->
            <div class="fanhuitop"><a href="#top" ref="nofollow"><img src="https://www.191i.com/static/old/img/fhtop.png"
                                                                      title="返回顶部"></a></div>
            <div class="dibu">
                <div class="dibu">



                </div>
            </div>
            <div class="banquan">
                <p>内容全部来源于网络收集,如有侵权,请联系网站删除:QQ:24596024</p>

            </div>
        </div>
    </div>
</div>

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?530214f19d678452e8fa4098a936ce38";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>
</html>