首页 > 代码库 > php curl

php curl

static function Curl($url, $preg) {

    $curl = curl_init();

    curl_setopt($curl, CURLOPT_URL, $url); //url 连接

    curl_setopt($curl, CURLOPT_HEADER, false); //返回都头信息

    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //以文本模式输出

    $data = http://www.mamicode.com/curl_exec($curl); //远程获取到的内容

    preg_match_all($preg, $data, $conent); //正则匹配

    return $conent;

}

php curl