我正在尝试从我所在的网站获取内容(文本),我发现了很多关于如何使用cURL登录并获取上下文的示例,但我不知道如何处理在我登录网站后进行重定向。我从下面的代码得到的结果是登录表单(Example #1 here)。我想知道我是否无法访问这是否真的可以做到?
$postdata = http_build_query(
array(
'Account' => 'myaccount',
'Password' => 'mypass'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://www.website.php/login.php', false,
$context);
登录成功后,我期望从重定向的网址获取文字,该文字看起来像http://www.website.php/other.php