PHP - 卷曲网站背后的免责声明表格

时间:2016-09-14 02:59:16

标签: php forms curl post

我试图用curl解析一个网站。 但是第一个屏幕是空表格。 到目前为止,我收到了一个错误(301-302) 这是我的代码:

<?php

$url = "https://www.interiorhealth.ca/HedgehogPortal/?returnUrl=/HedgehogPortal/facility/Table";
$url_redirect = "https://www.interiorhealth.ca/HedgehogPortal/facility/Table";

define('USER_AGENT', 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.2309.372 Safari/537.36');
define('COOKIE_FILE', 'cookie.txt');
define('FORM_URL', $url);
define('REDIRECT_URL', $url_redirect);

$postValues = array();

//Initiate cURL.
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, REDIRECT_URL);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postValues));

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($curl, CURLOPT_COOKIEJAR, COOKIE_FILE);
curl_setopt($curl, CURLOPT_USERAGENT, USER_AGENT);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_REFERER, FORM_URL);

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);

$server_output = curl_exec($curl);

//Check for errors!
if(curl_errno($curl)){
    throw new Exception(curl_error($curl));
} else {
    echo $server_output;
}
?>

任何帮助或指示都将很高兴。 谢谢!

0 个答案:

没有答案