Home > Backend Development > PHP Tutorial > php怎么指定大小的采集页面,比如说只要hearder部分

php怎么指定大小的采集页面,比如说只要hearder部分

WBOY
Release: 2016-06-13 10:48:04
Original
943 people have browsed it

php如何指定大小的采集页面,比如说只要hearder部分
如题:file_get_contents不能用,不太稳定。有没有其它方法?

------解决方案--------------------

PHP code
$curl = 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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template