1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <?php
$url1 = "https://google.fr";
$url2 = "https://www.google.de/";
$url3 = "https://example.com";
$nodes = array($url1, $url2, $url3);
$node_count = count($nodes);
$curl_arr = array();
$master = curl_multi_init();
for($i = 0; $i < $node_count; $i++)
{
$url =$nodes[$i];
$curl_arr[$i] = curl_init($url);
curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
//curl_setopt($curl_arr[$i], CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($curl_arr[$i], CURLOPT_COOKIEJAR, dirname(__FILE__) . "cookie$i.txt");
curl_setopt($curl_arr[$i], CURLOPT_COOKIEFILE, dirname(__FILE__) . "cookie$i.txt");
curl_setopt($curl_arr[$i], CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl_arr[$i], CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_arr[$i], CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl_arr[$i], CURLOPT_VERBOSE, true);
curl_multi_add_handle($master, $curl_arr[$i]);
}
do {
curl_multi_exec($master,$running);
} while($running > 0);
for($i = 0; $i < $node_count; $i++)
{
$results[] = curl_multi_getcontent ( $curl_arr[$i] );
echo curl_getinfo($curl_arr[$i], CURLINFO_HTTP_CODE);
//file_put_contents("result$i.html",$results[$i]);
} |
Partager