欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

curl cookiejar 获取不到内容,该怎么解决

程序员文章站 2022-05-04 09:09:48
...
curl cookiejar 获取不到内容

curlImage();
function curlImage(){
$cookieJar=tempnam('tmp', cookieImage);
$ch=curl_init("http://124.160.104.166/(1jovmraaf1pemj55dkr01ebo)/CheckCode.aspx");
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieJar);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$image=curl_exec($ch);
curl_close($ch);
$fp=fopen("image.gif", "w+");
fwrite($fp, $image);

}






这段代码是获取验证码加上cookie得可是每次看cookieImage文件都是空得
这是为什么?[yabao=][/yabao][yabao=][/yabao]


------解决思路----------------------
print_r(get_headers('http://124.160.104.166/'));
Array
(
[0] => HTTP/1.1 302 Found
[1] => Connection: close
[2] => Date: Thu, 02 Oct 2014 03:05:03 GMT
[3] => Server: Microsoft-IIS/6.0
[4] => X-Powered-By: ASP.NET
[5] => X-AspNet-Version: 1.1.4322
[6] => Location: /(mggxrgvmym2tzn45b5wfkh55)/default2.aspx
[7] => Cache-Control: private
[8] => Content-Type: text/html; charset=gb2312
[9] => Content-Length: 158
[10] => HTTP/1.1 200 OK
[11] => Connection: close
[12] => Date: Thu, 02 Oct 2014 03:05:04 GMT
[13] => Server: Microsoft-IIS/6.0
[14] => X-Powered-By: ASP.NET
[15] => X-AspNet-Version: 1.1.4322
[16] => Pragma: no-cache
[17] => Cache-Control: no-cache
[18] => Pragma: no-cache
[19] => Expires: -1
[20] => Content-Type: text/html; charset=gb2312
[21] => Content-Length: 4091
)

显然跳转中的形如 (mggxrgvmym2tzn45b5wfkh55) 的路径是充当 session 的角色的
------解决思路----------------------
顶上说的对啊
curl cookiejar 获取不到内容,该怎么解决

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频