<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ### :-: 一、`file()` 把整個文件讀入一個數組中 **參數**|**描述** ---|--- path| 必需。規定要讀取的文件。 include_path| 可選。如果也想在 include_path 中搜尋文件的話,可以將該參數設為 "1"。 context| 可選。規定文件句柄的環境。是一套可以修改流的行為的選項。若使用 null,則忽略。 > 示例: ```php //抓取的網址 $url = 'http://news.people.com.cn/210801/211150/index.js'; //將讀取內容存在數組中 $arr = file($url); print_r($arr); ``` --- ### :-: 二、`file_get_contents()` 把整個文件讀入一個字符串中 **參數**|**描述** ---|--- path| 必需。規定要讀取的文件。 include_path| 可選。如果也想在 include_path 中搜尋文件的話,可以將該參數設為 "1"。 context| 可選。規定文件句柄的環境。是一套可以修改流的行為的選項。若使用 null,則忽略。 start| 可選。規定在文件中開始讀取的位置。該參數是 PHP 5.1 新加的。 max_length| 可選。規定讀取的字節數。該參數是 PHP 5.1 新加的。 > 示例: ```php //抓取的網址 $url = 'http://news.people.com.cn/210801/211150/index.js'; //將讀取內容存在字符串中 $arr = file_get_contents($url); echo $arr; ``` ### :-: 三、`curl()` libcurl庫 **常用函數**|**描述** ---|--- curl_init()| 初始化 cURL 會話 curl_setopt()| 設置 cURL 傳輸選項 curl_exec()| 執行 cURL 會話 curl_errno()| 返回最后一次的錯誤代碼 curl_close()| 關閉 cURL 會話 > 需要重點說下: > curl_setopt() 設置 cURL 傳輸選項 > curl 可以post提交 > curl 可以獲取https **curl_setopt 參數**|**描述** ---|--- ch| 由 curl_init() 返回的 cURL 句柄 option| 需要設置的CURLOPT_XXX選項。(curl的關鍵部分,看下面示例) vlues| 設置值 > 示例: ```php header("Content-Type: text/html;charset=utf8"); // url可以是文件,可以是pc頁面,也可以是接口 // $url = 'https://mat1.gtimg.com/pingjs/ext2020/configF2017/5a9cf828.js'; $url = 'http://news.cctv.com'; // $url = 'https://pacaio.match.qq.com/irs/rcd?cid=146&token=49cbb2154853ef1a74ff4e53723372ce&ext=ent&page=2'; $ch = curl_init(); // 創建一個新cURL資源 curl_setopt($ch, CURLOPT_URL, $url); // 設置URL curl_setopt($ch, CURLOPT_TIMEOUT, 30); // 設置超時限制防止死循環 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// 爬取重定向頁面 curl_setopt($ch, CURLOPT_AUTOREFERER, 1); // 自動設置Referer,防止盜鏈 curl_setopt($ch, CURLOPT_POST, 1); // 發送一個常規的Post請求 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);// Post提交的數據包 curl_setopt($ch, CURLOPT_HEADER, 0); // 顯示返回的Header區域內容 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 要求結果保存到字符串中還是輸出到屏幕上 // 禁用SSL證書的驗證,就可以解決HTPPS獲取不到的問題 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);// 對認證證書來源的檢查 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);// 從證書中檢查SSL加密算法是否存在 curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); // 默認值,讓 cURL 自己判斷使用哪個版本。 (強制使用 HTTP/1.1)。 curl_setopt($ch, CURLOPT_USERAGENT, 'Data'); // 在HTTP請求中包含一個"User-Agent: "頭的字符串。 $html = curl_exec($ch); // 運行cURL,請求URL,把結果復制給變量 if(curl_errno($ch)){ echo 'Errno'.curl_error($curl); //捕抓異常 } curl_close($ch); // 關閉cURL連接 print_r($html); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看