post 抓取

function curlBy($url, $data=array()){
        $ch = curl_init();
        if(!empty($data)){
            if (is_array($data) && $data) {
                $formdata = http_build_query($data);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $formdata);
            }
        }
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT,0);
        $result = curl_exec($ch);
        return $result;
    }

posted @ 2014-07-03 18:05  kwishly  阅读(309)  评论(0编辑  收藏  举报