2016-11-19 37 views
1

我想放棄這個網站 - marcanet.impi.gob.mx/marcanet/controler/RegistroBusca刮,捲曲後不放棄的結果

下面是我使用的代碼,但我沒有得到的結果頁。

$form_url = "http://marcanet.impi.gob.mx/marcanet/controler/RegistroLista"; 
$data_to_post = array(); 
$data_to_post['registro'] = '1384641'; 
$curl = curl_init(); 

curl_setopt($curl,CURLOPT_URL, $form_url); 
curl_setopt($curl,CURLOPT_POST, sizeof($data_to_post)); 
curl_setopt($curl,CURLOPT_POSTFIELDS, $data_to_post); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); 
curl_setopt($curl, CURLOPT_COOKIE, "fruit=apple; colour=red"); 
curl_setopt($curl,CURLOPT_HTTPHEADER,array('Host: marcanet.impi.gob.mx', 'Accept-Language: en-US,en;q=0.5', 'Referer: http://marcanet.impi.gob.mx/marcanet/controler/RegistroBusca')); 

$result = curl_exec($curl); 
$dom = new simple_html_dom(); 
$htm = $dom->load($result); 

echo $htm; 

這給我的結果是沒有找到註冊號。請幫忙。

+0

你的意思是「我想刮這個網站」? – bradfordrg

+0

是的。我想刮這個網站。 –

回答

0

你想用一個字符串作爲後身體:

$data_to_post = 'registro=1384641'; 

否則捲曲將將其作爲多形式的數據。

此外,您的一些選項看起來不正確,如果您不小心,Host:標題將會讓您陷入麻煩。 More info on the options can be found here