Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $start_sec = date('U');
- do{
- LOG::Write_to_log('cycle start');
- $current_sec = date('U');
- $responses = multirequest($urls);
- save_resp($responses);
- }
- while
- ($current_sec != $start_sec + 1);
- LOG::Write_to_log('cycle start');
- function multirequest($urls)
- {
- $multi = curl_multi_init();
- $handles = [];
- $htmls = [];
- for($i=0; $i<count($urls);$i++)
- {
- $ch = curl_init($urls[$i]);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
- //curl_setopt($ch, CURLOPT_PROXY, '1.2.3.4:80');
- curl_multi_add_handle($multi, $ch);
- array_push($handles, $ch);
- }
- do {
- $mrc = curl_multi_exec($multi, $active);
- } while ($mrc == CURLM_CALL_MULTI_PERFORM);
- while ($active && $mrc == CURLM_OK)
- {
- if (curl_multi_select($multi) == -1)
- {
- usleep(1);
- }
- do
- {
- $mrc = curl_multi_exec($multi, $active);
- }while($mrc == CURLM_CALL_MULTI_PERFORM);
- }
- foreach($handles as $channel)
- {
- $html = curl_multi_getcontent($channel);
- $htmls[] = $html;
- curl_multi_remove_handle($multi, $channel);
- }
- curl_multi_close($multi);
- return $htmls;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement