php抓取http包头文件
简单的一个函数:get_header($URL)
get_headers — Fetches all the headers sent by the server in response to a HTTP request
抓取服务器端响应http请求发送的头信息
<?php
$url = ‘http://www.sina.com’;
echo “<pre>”;
print_r(get_headers($url));
print_r(get_headers($url, 1));
echo “</pre>”;
?>
返回结果
Array(
[0] => HTTP/1.0 200 OK
[1] => Date: Sun, 09 Dec 2007 13:43:55 GMT
[2] => Server: Apache/2.0.54 (Unix)
[3] => Last-Modified: Sun, 09 Dec 2007 13:42:52 GMT
[4] => ETag: “86f1a9-4b613-a7f8ef00″
[5] => Accept-Ranges: bytes
[6] => X-Powered-By: mod_xlayout_jh/0.0.1vhs.markII.remix
[7] => Cache-Control: max-age=60
[8] => Expires: Sun, 09 Dec 2007 13:44:55 GMT
[9] => Vary: Accept-Encoding [10] => Content-Type: text/html
[11] => Age: 58
[12] => X-Cache: HIT from xa-174.sina.com.cn
[13] => Connection: close)
Array(
[0] => HTTP/1.0 200 OK
[Date] => Sun, 09 Dec 2007 13:47:44 GMT
[Server] => Apache/2.0.54 (Unix)
[Last-Modified] => Sun, 09 Dec 2007 13:42:52 GMT
[ETag] => “86f1a9-4b613-a7f8ef00″
[Accept-Ranges] => bytes
[X-Powered-By] => mod_xlayout_jh/0.0.1vhs.markII.remix
[Cache-Control] => max-age=60
[Expires] => Sun, 09 Dec 2007 13:48:44 GMT
[Vary] => Accept-Encoding
[Content-Type] => text/html
[X-Cache] => MISS from xa-172.sina.com.cn
[Connection] => close)
近期评论