废话非常少说一向上代码
分类:博客热点

php 模拟登陆$url = ;$useragent = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TheWorld);$cookie = dznet_cookietime=2592000;dznet_onlineusernum=7816;dznet_sid=QtlC87;dznet_auth=6bbeCQrzGv4eliNMLgU%2FlGZSpzbrsauGO1l0OBp6VQw5p0bcEg0xd4slYCM2ks%2FL0YCVYSO7XP2z8GMaxkPDUbXZCWft;checkpm=1;$ch= curl_init();curl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_COOKIE, $cookie);curl_setopt($ch, CURLOPT_REFERER, );curl_setopt($ch, CURLOPT_HEADER, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);curl_exec($ch);$tempCn = curl_multi_getcontent($ch);curl_close($ch);echo $tempCn;

废话不多说直接上代码

/********************** curl 系列 ***********************/
//直接通过curl方式取得数据(包含POST、HEADER等)
/*
 * $url: 如果非数组,则为http;如是数组,则为https
 * $header: 头文件
 * $post: post方式提交 array形式
 * $cookies: 0默认无cookie,1为设置,2为获取
 */
public function curl_allinfo($urls, $header = FALSE, $post = FALSE, $cookies = 0) {
    $url = is_array($urls) ? $urls['0'] : $urls;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    //带header方式提交
    if($header != FALSE){
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    }

    //post提交方式
    if($post != FALSE){
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    }

    if($cookies == 1){
        curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
    }else if($cookies == 2){
        curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
    }

    if(is_array($urls)){
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    }

    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

本文由威尼斯在线注册平台发布于博客热点,转载请注明出处:废话非常少说一向上代码

上一篇:供销合作社安插在那伦敦召开的搜寻引擎战略大会(Search 下一篇:没有了
猜你喜欢
热门排行
精彩图文