douwei4370 2012-09-22 20:42
浏览 8
已采纳

PHP cURL快速检查网站是否存在[重复]

Possible Duplicate:
cURL Mult Simultaneous Requests (domain check)

I'm trying to check to see if a website exists. (if it responds that's good enough) The issue is my array of domains is 20,000 and I'm trying to speed up the process as much as possible.

I've done some research and come across this page which details simultaneous cURL requests -> http://www.phpied.com/simultaneuos-http-requests-in-php-with-curl/

I also found this page which seems be a good way of checking if a domain webpage is up -> http://www.wrichards.com/blog/2009/05/php-check-if-a-url-exists-with-curl/

Any ideas on how to quickly check 20,000 domains to see if they are up?

  • 写回答

4条回答 默认 最新

  • dongtiaobeng7901 2012-09-22 20:52
    关注

    check out RollingCurl

    It allows you to execute multiple curl requests. Here is an example:

        require 'curl/RollingCurl.php';
        require 'curl/RollingCurlGroup.php';
    
    
        $rc = new RollingCurl('handle_response');
                $rc->window_size = 2;
    
    
    
    
                foreach($domain_array as $domain => $value)
                {
    
    
    
    
    
    
                     $request = new RollingCurlRequest($value);
    
                    // echo $temp . "
    ";
    
    
                        $rc->add($request);
    
    
    
    
                }
    
                $rc->execute();
    
    
    
    
        function handle_response($response, $info)
        {
    
                if($info['http_code'] === 200)
                {
                    // site exists handle response data
                }
    
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)