php只请求网页文件的大小,不返回网页内容,该怎么解决

WBOY
Release: 2016-06-13 11:47:37
Original
764 people have browsed it

php只请求网页文件的大小,不返回网页内容,
实际情况是这样的,,我一次性要分析上万个网站的导出链接,所以要下载源代码,

而实际上有些网站的源代码非常长,会妨碍我程序执行的效率,所以我想在不返回网页内容的前提下获取网页文件的大小,之后才判断是否执行分析
------解决方案--------------------
print_r(get_headers('http://forum.csdn.net/PointForum/Manage/TopicManageView.aspx?forumID=94985a29-c8e9-4552-9be4-b01061443744&topicID=0758c3a4-5c85-4434-8a26-0d2c9ccc4c45&date=2012-09-06+21%3a18%3a02&v=-1', 1));


Array
(
    [0] => HTTP/1.1 200 OK
    [Server] => nginx/0.7.68
    [Date] => Thu, 06 Sep 2012 13:29:26 GMT
    [Content-Type] => text/html; charset=utf-8
    [Connection] => close
    [Vary] => Accept-Encoding
    [ETag] => ""
    [X-UA-Compatible] => IE=EmulateIE7
    [X-Powered-By] => ASP.NET
    [Cache-Control] => private
    [Content-Length] => 4410
)

------解决方案--------------------
这个很少用。学习了。
------解决方案--------------------
get_headers() 返回一个数组,包含有服务器响应一个 HTTP 请求所发送的标头。如果失败则返回 FALSE 并发出一条 E_WARNING 级别的错误信息。


 如果将可选的 format 参数设为 1,则 get_headers() 会解析相应的信息并设定数组的键名。

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!