21,886
社区成员
发帖
与我相关
我的任务
分享
private function getCaptcha(){
$cookieJar=tempnam('tmp', cookieJar);
$header=array(
'Host: dlpa.dl.gov.cn',
'Connection: keep-alive',
'Cache-Control: max-age=0',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36',
'Referer: http://dlpa.dl.gov.cn/zzb/dclist_16.html',
'Accept-Encoding: gzip,deflate,sdch',
'Accept-Language: zh-CN,zh;q=0.8',
'RA-Ver: 2.7.0',
'RA-Sid: B7F612F3-20140422-090030-f3dd41-07c579',
); //不知道它有没有验证什么所以直接整个头复制下来了
$this->url='http://dlpa.dl.gov.cn/zzb/authImg';
$ch=curl_init($this->url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieJar);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$image=curl_exec($ch);
curl_close($ch);
$fp=fopen('captcha.jpg', 'w+');
fwrite($fp, $image);
}
echo '<img src="captcha.jpg"><br />'
header('content-type:image/jpeg');
$authImg = file_get_contents('http://dlpa.dl.gov.cn/zzb/authImg');
echo $authImg;