2012-04-13 4 views
3

나는 cURL을 사용하여 웹 페이지의 콘텐츠를 가져 오려고했지만 쿠키를 허용하는 데 문제가 있습니다. 예를 들어, Target.com에서 내가 그것을 cURL 때, 나는 여전히 쿠키를 활성화해야한다고 말합니다. 여기 cURL을 사용하여 쿠키 수락 하시겠습니까?

내 코드입니다 :

$url = "http://www.target.com/p/Acer-Gateway-15-6-Laptop-PC-NV57H77u-with-320GB-Hard-Drive-4GB-Memory-Black/-/A-13996190#?lnk=sc_qi_detailbutton"; 
$ch = curl_init(); // initialize curl handle 
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to 
curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable 
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out after 4s 
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20100101 Firefox/11.0"); 
$cookie_file = "cookie1.txt"; 
curl_setopt($ch, CURLOPT_COOKIESESSION, true); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); 
$result = curl_exec($ch); // run the whole process 
curl_close($ch); 
echo $result; 
내가 놓친 거지 뭐가

? 그런데 cookie1.txt 파일은 077 권한입니다.

+4

077이 잘못된 권한이므로 소유자 (아마 아파치)가 액세스 권한이 없음을 의미합니다. 파일로만 644로 설정해보십시오. –

+0

@MikePurcell 왜 댓글로 게시 하시겠습니까? 답으로 게시하십시오. –

+1

@ Truth : 유형인지 아닌지 확실하지 않았습니다. –

답변

4

077이 잘못된 형식의 권한 설정이므로 소유자 (아마 아파치)가 액세스 할 수 없음을 의미합니다. 파일로만 644 (소유자는 읽기/쓰기 가능)로 설정해보십시오.

+2

안녕하세요, 문제를 파악 했습니까? –

관련 문제