Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $urls = array("ya.ru","google.ru","asdfasdfasfas.org","habr.ru");
- $tasks = array();
- $mh = curl_multi_init();
- foreach($urls as $url)
- {
- $h = curl_init("http://".$url);
- curl_setopt($h,CURLOPT_FOLLOWLOCATION,1);
- curl_setopt($h,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($h,CURLOPT_HEADER,0);
- curl_multi_add_handle($mh,$h);
- $tasks[$url] = $h;
- }
- $act = 0;
- do
- {
- curl_multi_exec($mh,$act);
- $info = curl_multi_info_read($mh);
- if($info["msg"] == CURLMSG_DONE)
- {
- $h = $info["handle"];
- $url = array_search($h,$tasks);
- $tasks[$url] = curl_multi_getcontent($h);
- curl_multi_remove_handle($mh,$h);
- curl_close($h);
- }
- }
- while($act > 0);
- curl_multi_close($mh);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement