php - 判断远程图片存在并抓取
迷茫
迷茫 2017-04-11 08:58:06
0
1
689

$curl = curl_init();

    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HEADER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//关闭证书
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT,8);
    $file = curl_exec($curl);
    curl_close($curl);

当我胡乱编一个地址时,域名超过7个字符时,例如:http://www.ffafffe.com/up358.jpg
得到的$file打印为:
string(686) "<html><head></head><script type="text/javascript">
var sa = "http://202.102.110.207:8080/"; var pp = "108&pre="+(new Date()).getTime();
var s=String(window.location.href); var host=escape(s.substring(7,s.indexOf('/',7)));
var ref=escape(document.referrer); var su = s+"&host="+host+"&refer="+ref+"&server="+pp;
s = escape(s); function loadfr(){ document.getElementById("fr1").src = sa+"3.htm?AIMT="+su; }
function refreshPage(){ document.location = sa+"2.htm?AIMT="+su; }
if (self.location == top.location){ document.location= sa+"1.htm?AIMT="+su; }
else { refreshPage(); }</script><frameset rows="*,0"><frame id="main" src="">
<frame id="fr1" src=""></frameset><body></body></html>

为什么,有没有解决办法

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
左手右手慢动作

查看响应header的content-type,为image/* 的基本就是图片了,也有的站点给你返回一个默认的图片,不过这就是另一个问题了

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template