我尝试使用以下脚本向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);
?>
当我运行脚本时,我得到了#34;访问被拒绝。出于安全原因,您的请求已被拒绝。&#34;
脚本是否会触发某些安全机制,或者只是发出错误的请求?
提前,
卢卡斯
答案 0 :(得分: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);