使用php检查来自主机的链接


Checking link from a host with php

我得到了一些链接,一些在rapidshare和其他上传主机上。我如何检查链接上的文件是否仍在工作?

我尝试了curl和file_get_contents。在一些主机上curl工作,在其他file_get_contents工作,但大多数不会返回页面源代码,所以我不能搜索字符串"已删除"或类似的东西。

有什么办法可以做到吗?

编辑:这是新的代码,仍然不能工作:

function curl_download($Url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
$agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch,CURLOPT_VERBOSE,false);
   curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch,CURLOPT_SSLVERSION,3);
   curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
函数访问($ url) {$agent = "Mozilla/4.0(兼容;MSIE 5.01;Windows NT 5.0);$ ch = curl_init ();curl_setopt ($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_USERAGENT, $agent);curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ ch CURLOPT_VERBOSE假);curl_setopt($ch, CURLOPT_TIMEOUT, 5);curl_setopt ($ ch CURLOPT_SSL_VERIFYPEER假);curl_setopt (ch美元CURLOPT_SSLVERSION 3);curl_setopt ($ ch CURLOPT_SSL_VERIFYHOST假);(页面= curl_exec美元ch);//echo curl_error (ch);$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);curl_close (ch);If ($ httpcode<=200 && $httpcode<300) return true;否则返回false;}如果访问("http://www.google.com"))echo "Website OK"."n";其他的echo"网站关闭";