php获取其他网页内容并显示部分内容

2025-03-28 01:37:35
推荐回答(1个)
回答1:

用正则表达式,是最快的,你看下面:

$url = 'http://www.baidu.com'; //这儿填页面地址
$info=file_get_contents($url);
preg_match('|(.*?)<\/title>|i',$info,$m);<br>echo $m[1];<br>?></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://191i.com/i/135906798675359925.html">Windows Server 2008的服务器怎么添加角色</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/1952490283101790068.html">桂林位于新乡什么方位</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/938769666720182212.html">我家里住农村,使用的水说是深井水,但是用起来很滑,洗手像洗不干净似的,跟打了香皂似的怎么回事</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/50271594.html">盐水的咸味是由 钠离子 决定还是 氯离子 决定的?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/98789018.html">给2岁半的男孩送什么礼物才能给孩子个惊喜</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/1703324144703273420.html">因特尔5820K这个CPU,对应的内存条据说必须是DDR4的。但我在京东搜索了一下,DDR4的台式</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/2144816438170677428.html">不锈钢锻件有哪些加工方法呢?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/99660918.html">我妹妹长得怎么样?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/307390111177816484.html">2016年西安电子科技大学新生在哪个校区及新生开学报到时间</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://191i.com/i/1691459915298684948.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://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>