0
Curl Multi Init에 문제가 있습니다. 동시에 여러 사이트를 방문한 다음 해당 콘텐츠를 변수에 저장하려고합니다. 불행히도 각 사이트의 콘텐츠가 왜 반향을 일으키는 지 알 수 없습니다. 예를 들어 사이트에있는 콘텐츠 중 하나가 "안녕하세요"이고 다른 하나가 "안녕하세요"라는 두 개의 사이트로 이동한다고 말하면 '안녕하세요'라는 메시지가 표시됩니다. 이유가 확실하지 않습니다. 다음은 내가 사용하고있는 코드입니다.Curl Multi Init 실행 페이지의 내용을 에코하기
<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();
// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://example1.org/");
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://example2.org/");
curl_setopt($ch2, CURLOPT_HEADER, 0);
//create the multiple cURL handle
$mh = curl_multi_init();
//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
$active = null;
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) == -1) {
usleep(100);
}
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);
?>
이것은 정확히 필요할 수 있습니다. http://stackoverflow.com/a/19639422/541091 –