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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:13:10
Original
877 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
Latest Issues
curl simulated login
From 1970-01-01 08:00:00
0
0
0
Convert cURL command line to PHP cURL code
From 1970-01-01 08:00:00
0
0
0
Convert command line cURL to PHP cURL
From 1970-01-01 08:00:00
0
0
0
How to set boolean value true in php curl
From 1970-01-01 08:00:00
0
0
0
Please tell me, php curl request page shows blank
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template