我用下面的代码echo = file_get_contents('http://www.pig-cat.com/index2.php?feed=rss2');无法获得内容,但是直接访问http://www.pig-cat.com/index2.php?feed=rss2却可以(被跳转到了http://www.pig-cat.com/index2.php/feed)。请问大家怎么才能获得http://www.pig-cat.com/index2.php?feed=rss2的代码呢?(假设不知道会不会跳转以及跳转到哪)。谢谢大家~
echo file_get_contents('http://www.pig-cat.com/index2.php?feed=rss2');
你怎么怎样写啊 应这样写啊:
echo file_get_contents('http://www.pig-cat.com/index2.php?feed=rss2');
if (!$fp) {
die($error->show_error($lang[failure],$lang[format_error]));
} else {
$out = "GET /{$L}pv/{$cid}d.html HTTP/1.1\r\n";
$out .= "Host: xxx.com\r\n";
$out .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
$i=1;
while (!feof($fp)&&$i<1000) {
$c.= fgets($fp, 1024);
$i++;
}
fclose($fp);
}
自己找点资料吧.
echo file_get_contents('http://www.pig-cat.com/index2.php?feed=rss2');
?>这样不行。大家能不能帮忙测试一下呢?fsockopen速度有些慢。
如果浏览器能直接访问,哪就注意以下几点.
伪造user_agent,refer,
有些网站还需要cookie