2017-04-03 49 views
-1

我嘗試使用下面的腳本張貼到http://iate.europa.eu/請求:捲曲後請求失敗 - 在一個腳本錯誤或受阻?

 <?php 

$output_array = array(); 

$post = "method=search&saveStats=true&screenSize=1920x1080&query=bond&valid=Szukaj+&sourceLanguage=en&targetLanguages=pl&domain=&domain=12&typeOfSearch=s&request="; 

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL, 'http://iate.europa.eu/SearchByQueryEdit.do'); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

echo $server_output = curl_exec ($ch); 

?> 

我使用的數據: enter image description here

當我運行該腳本,我得到「拒絕訪問您的要求了。因安全原因被拒絕。「

該腳本是否觸發了一些安全機制或者它是否只是做出錯誤的請求?

Thx提前,

盧卡斯

回答

0

我已經添加的試劑。試試這個:

$post = "method=search&saveStats=true&screenSize=1920x1080&query=bond&valid=Szukaj+&sourceLanguage=en&targetLanguages=pl&domain=&domain=12&typeOfSearch=s&request="; 

$ch = curl_init(); 

/* Additional Code Start */ 
$agent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0";   
curl_setopt($ch, CURLOPT_USERAGENT, $agent); 
/* Additional Code End*/ 

curl_setopt($ch, CURLOPT_URL, 'http://iate.europa.eu/SearchByQueryEdit.do'); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

echo $server_output = curl_exec ($ch); 
+0

感謝。該腳本將獲取的數據,但不是我想要的數據。它只是迴應起始頁面。你可以看看http://iate.europa.eu/和我的'$ post'變量嗎? –

+0

你還需要幫助嗎?我可以具體來看,明天的問題。 –