• php curl打开网页


    function get_web_page( $url )
    {
    $options = array(
    CURLOPT_RETURNTRANSFER => true,     // return web page 返回网页
    CURLOPT_HEADER         => false,    // 不返回头信息
    CURLOPT_FOLLOWLOCATION => true,     // follow redirects
    CURLOPT_ENCODING       => "",       // handle all encodings
    CURLOPT_USERAGENT      => "spider", // 设置UserAgent
    CURLOPT_AUTOREFERER    => true,     // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect 连接超时
    CURLOPT_TIMEOUT        => 120,      // timeout on response 回复超时
    CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    );
    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );
    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;
    return $header;
    }

    如果出现

    Fatal error: Call to undefined function curl_init()  

    检查php.ini,在windows的xampp里 extension=php_curl.dll是默认注释的,去掉前面的分号就好。

  • 相关阅读:
    UISearchBar的常用代理
    iOS 上传图片压缩大小设置
    __weak typeof(self)weakSelf = self;的解释和使用
    运动事件(MotionEvent)
    iOS 获取当前window
    保留小数
    ios 转图片
    iOS提示弹窗
    iOS 获取ip地址
    微信小程序 watch监听数据变化 类似vue中的watch
  • 原文地址:https://www.cnblogs.com/likwo/p/2167757.html
Copyright © 2020-2023  润新知