<div class="chartInfo"> <div class="line"></div> <div class="tideTable"> <strong>潮汐表</strong><span style="font-size:12px;font-weight:lighter;margin-left:-20px;">数据仅供参考</span> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tbody><tr> <td width="100"><p><span>潮时 (hrs)</span></p></td> <td width="100"><p>00:58</p></td> <td width="100"><p>05:20</p></td> <td width="100"><p>13:28</p></td> <td width="100"><p>21:15</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</p></td> </tr> <tr> <td><p><span>潮高 (cm)</span></p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1675">
<img src="https://img.php.cn/upload/ai_manual/000/969/633/68b6d5b124798234.png" alt="百度文心百中">
</a>
<div class="aritcle_card_info">
<a href="/ai/1675">百度文心百中</a>
<p>百度大模型语义搜索体验中心</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="百度文心百中">
<span>22</span>
</div>
</div>
<a href="/ai/1675" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="百度文心百中">
</a>
</div>
</td> <td width="100"><p>161</p></td> <td width="100"><p>75</p></td> <td width="100"><p>288</p></td> <td width="100"><p>127</p></td> </tr> </tbody></table> <h2>时区:-1000 (东10区) 潮高基准面:在平均海平面下174CM</h2> </div> <div class="chart"> <!--<img src="http://www.cnss.com.cn/statics/images/cnss/tide/tide.jpg" style="max-width:90%" style="max-width:90%" title="" alt="" /> --> </div> </div>这是源程序里边的一部分,为了容易看懂,删减了一大部分,只取<span style="font-family: Arial, Helvetica, sans-serif;"><div class="tideTable"> div块中的内容</span>
<span style="font-family: Arial, Helvetica, sans-serif;">首页先用file_get_content或curl获取内容部分,我用的是curl。</span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="white-space:pre"></span><span style="white-space:pre"> </span>$ch = curl_init();<span style="white-space:pre"> </span>curl_setopt($ch, CURLOPT_URL, $url);<span style="white-space:pre"> </span>curl_setopt($ch, CURLOPT_POST, 1);<span style="white-space:pre"> </span>curl_setopt( $ch, CURLOPT_HEADER, 0 );<span style="white-space:pre"> </span>curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );<span style="white-space:pre"> </span>curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );<span style="white-space:pre"> </span>$return = curl_exec( $ch );<span style="white-space:pre"> </span>curl_close( $ch );<span style="white-space:pre"> </span><span style="white-space:pre"> </span>$regex4="/<div class=\"tideTable\".*?>.*?<\/div>/ism";<span style="white-space:pre"> </span>if(preg_match_all($regex4, $return, $matches)){ <span style="white-space:pre"> </span> print_r($matches);<span style="white-space:pre"> </span>}else{<span style="white-space:pre"> </span>echo '0';<span style="white-space:pre"> </span>}</span><span style="font-family:Arial, Helvetica, sans-serif;">这样就可以了,不多解释,懂PHP的看代码,打印看一下效果。</span>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号