1
우리는 로봇의 진정한 컬 요청을 걸러 내기위한 과제를 가지고 있습니다. 사이트에 컬 요청을 보내고 있지만 잘못된 이미지 파일이 반환됩니다 (브라우저에서 볼 때 작동하기 때문에 알 수 있습니다). 그것은 어떻게 든 나의 요구가 확실하지 않다는 것을 안다. 여기에 간과되는 필드가 있습니까, 브라우저 요청을 정확하게 모방하려고합니다.컬 (curl) 요청을위한 브라우저 헤더
$header_arr = array(
'0' =>'Host: www.myittest.com',
'1' =>'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0',
'2' =>'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*\/*;q=0.8',
'3' =>'Accept-Language: en-US,en;q=0.5',
'4' =>'Accept-Encoding: gzip, deflate',
'5' =>'Connection: keep-alive',
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_arr);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 6);
$raw=curl_exec($ch);
시도해보십시오. $ ch = curl_init(); '$ ch = curl_init ($ url); 대신'curl_setopt ($ ch, CURLOPT_URL, $ url);' –