zoukankan      html  css  js  c++  java
  • PHP Curl会话请求

    /**
     * @param string $url 请求地址
     * @param string $type 请求类型 post  get
     * @param string $arr 如果是post 传递的数据
     * @return mixed|	hink
    esponseJson
     */
    function http_curl($url,$type = 'get', $arr ='' ){
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, 0); //设置header
        curl_setopt($ch , CURLOPT_URL,$url);//设置访问的地址
        curl_setopt($ch , CURLOPT_RETURNTRANSFER,1);//获取的信息返回
        if($type == 'post'){
            curl_setopt($ch,CURLOPT_POST,1);
            curl_setopt($ch,CURLOPT_POSTFIELDS,$arr);
        }
        $output = curl_exec($ch);//采集
        if(curl_error($ch)){
            return curl_error($ch);
        }
        return $output;
    }
  • 相关阅读:
    @loj
    @codeforces
    @bzoj
    @hdu
    @poj
    @loj
    @bzoj
    @bzoj
    Python配合BeautifulSoup读取网络图片并保存在本地
    Java--多线程读取网络图片并保存在本地
  • 原文地址:https://www.cnblogs.com/wqy415/p/6824941.html
Copyright © 2011-2022 走看看