2011-09-21 111 views
-2

我使用file_get_contents()函数时遇到问题。PHP file_get_contents与www.skelbikas.lt不兼容

它工作正常,并通过从amazon.com搜索结果例如:file_get_contents(“http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps & field-keywords = java +编码& x = 0 & y = 0“);

但我需要得到的结果(保存为字符串)从的file_get_contents( “http://www.skelbikas.lt/paieska.php?kat=83 & zodis = iphone &傩= 0”); - 当我尝试这个时,它传递为字符串skelbikas.lt的索引页面。

问题在哪里?



感谢您的快速响应。

使用卷曲LIB的情况是一样的 - 与amazon.com正常工作 - 我得到的结果exam​​ple_homepage.txt,我试着写skelbikas.lt索引页 - 它工作得很好过,但http://www.skelbikas.lt/paieska.php?kat=83&zodis=taisymas&nuo=0不 - 什么也不写(空)到文件中。 :?

+0

编辑默认的PHP用户代理到一个类似于Internet Explorer的用户代理exampel – dynamic

回答

0

尝试使用卷曲

<?php 

$ch = curl_init("http://www.skelbikas.lt/paieska.php?kat=83&zodis=iphone&nuo=0"); 
$fp = fopen("example_homepage.txt", "w"); 

curl_setopt($ch, CURLOPT_FILE, $fp); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

curl_exec($ch); 
curl_close($ch); 
fclose($fp); 
?>