第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用 curl 登錄并多次移動(dòng)到另一個(gè)頁(yè)面

使用 curl 登錄并多次移動(dòng)到另一個(gè)頁(yè)面

PHP
波斯汪 2022-08-19 09:57:31
我正在嘗試登錄到一個(gè)網(wǎng)站并重定向到數(shù)組中聲明的頁(yè)面。我成功登錄,我得到了數(shù)組中的第一個(gè)網(wǎng)址。但是問(wèn)題是,當(dāng)我第二次循環(huán)通過(guò)代碼時(shí),我遇到了錯(cuò)誤。代碼:$url = 'https://url/signin';  $ch = curl_init($url);  $data = [    "e_mail" => "email@",    "password" => "123456"  ];  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // allow redirections  curl_setopt($ch, CURLOPT_POST, true); // we are making post request  curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //   curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); // COOKIEEjAR To save data for cookies created for login process  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // TRUE means dont just echo output the data instead we can store the request response in some variaable  $result = curl_exec($ch);  $urls_to_loop = array('url1', 'url2');foreach ($urls_to_loop as $key => $url) {          curl_setopt($ch, CURLOPT_URL, $url);          $exec = curl_exec($ch);          // echo($exec);          curl_close($ch);// close login CURL resource, and free up system resources          $html = new simple_html_dom();          $html->load($exec);  $links = [];  foreach($html->find('link') as $element){    if($element->href[-1] === '4'){      // check if url is not in the array      if(!in_array($element->href, $links)){        array_push($links, $element->href);      }    }   }}//END foreach這是錯(cuò)誤:警告:curl_setopt(): 提供的資源不是第 263 行 C:\xampp\htdocs\web\index.php中有效的 cURL 句柄資源警告:curl_exec(): 提供的資源不是第 264 行 C:\xampp\htdocs\web\index.php中有效的 cURL 句柄資源警告:curl_close(): 提供的資源不是第 267 行 C:\xampp\htdocs\web\index.php中有效的 cURL 句柄資源警告:curl_setopt(): 提供的資源不是第 263 行 C:\xampp\htdocs\web\index.php中有效的 cURL 句柄資源
查看完整描述

1 回答

?
德瑪西亞99

TA貢獻(xiàn)1770條經(jīng)驗(yàn) 獲得超3個(gè)贊

您正在循環(huán)期間關(guān)閉處理程序。

curl_close($ch);

將該行移到腳本的末尾。


查看完整回答
反對(duì) 回復(fù) 2022-08-19
  • 1 回答
  • 0 關(guān)注
  • 101 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)