php如何指定大小的采集页面,比如说只要hearder部分
如题:file_get_contents不能用,不太稳定。有没有其它方法?
------解决方案--------------------
$<a style="color:#f60; text-decoration:underline;" title="curl" href="https://www.php.cn/zt/17285.html" target="_blank">curl</a> = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_WRITEFUNCTION, 'func');//设置一个回调函数
$text = curl_exec($curl);
curl_close($curl);
echo $text;
function func($ch, $str) {
if(strstr($str, '你需要识别的串') return 0;//判断是否取到需要的内容
return strlen($str);
} <div class="clear"></div>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号