php - 判断远程图片存在并抓取
迷茫
迷茫 2017-04-11 08:58:06
[PHP讨论组]

$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>

为什么,有没有解决办法

迷茫
迷茫

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

全部回复(1)
ringa_lee

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号