开发者

curl_multi_init with different proxy for each handle?

开发者 https://www.devze.com 2023-03-15 06:39 出处:网络
i want to write a script using 开发者_JS百科curl_multi_init() but i must have to specify the curl_setopt() with my proxy only once and not for each handle, there is a way to solve this with different

i want to write a script using 开发者_JS百科curl_multi_init() but i must have to specify the curl_setopt() with my proxy only once and not for each handle, there is a way to solve this with different proxy for each handle?


i got the solution, specify the proxy that you want with a new curl_init() then add a new handle.

$master = curl_multi_init();
$curl_arr[1] = curl_init();
curl_setopt($curl_arr[1], CURLOPT_PROXY, $proxy);
curl_multi_add_handle($master, $curl_arr[1]);
do {
 curl_multi_exec($master,$running); //while there are running connections just keep looping
 } while($running > 0);
$data = curl_multi_getcontent($curl_arr[1]);

and ect.

0

精彩评论

暂无评论...
验证码 换一张
取 消