我想從網站上獲取一些數據。我有登錄憑證,我可以通過curl登錄,但是登錄過程有第二階段,我必須回答一個安全問題。使用curl處理動態url php
問題是我每次輸入用戶名,密碼重定向到不同的網址。
作爲例子: 登錄網址:https://url.com 登錄後:https://url?execution=e4s1&action=caDevicePrint(安全Q /頁)
這裏的執行= e4s1'就像e1s1,e1s2,e3s2登錄後改變的每次。
我想動態地設置CURLOPT_URL。以下是我的代碼:
$this->curl = curl_init();
curl_setopt($this->curl, CURLOPT_URL, "https://url?execution=e4s1&action=caDevicePrint");
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($this->curl, CURLOPT_USERAGENT,$this->userAgent);
curl_setopt($this->curl, CURLOPT_COOKIEJAR,$this->cookieFile);
curl_setopt($this->curl, CURLOPT_COOKIEFILE,$this->cookieFile);
$results = curl_exec($this->curl);
echo $results;
if (curl_errno($this->curl)) {
echo "Failed loading <br>";
var_dump(curl_error($this->curl));
die();
}
curl_close($this->curl);
你不說如何重定向工作,告訴我們,我們可能會有更多的幫助。它是一個http 300x'位置:'重定向? ''刷新重定向? JavaScript重定向?我們不能準確回答這個問題,沒有這個信息... – hanshenrik