我想从网站上获取一些数据。我有登录凭证,我可以通过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