0
如果有人可以幫我解決這個問題,那將會很棒。 這是我到目前爲止。當我運行這個並回顯dom內容時,我仍然遇到登錄頁面。但我看不出我做錯了什麼。PHP cURL帖子字段無法正常工作
$target_url = "https://secretsales.com/";
$fields = array('email' => 'abc', 'password' => '123');
$postFields = http_build_query($fields, '', '&');
// make the cURL request to $target_url
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$html = curl_exec($ch);
// parse the html into a DOMDocument
$dom = new DOMDocument();
@$dom -> loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
echo $dom->saveHTML();
我只能在這裏猜測,但我認爲該網站需要在登錄之前設置一個cookie。還可以有其他安全檢查,如xsrf標記。 – scones 2013-02-09 15:10:47