2012-02-05 94 views

回答

1

尝试:

echo htmlentities(file_get_contents('http://stackoverflow.com/questions/ask')); 
+0

非常感谢。此代码适用于给定的网址。但它不适用于'http://www.maduraonline.com/?find=home'。它只是显示网页。任何想法为什么这是?我想要这个网页的HTML代码,因为我正在开发一个翻译。我能做些什么来获得它的HTML代码? 非常感谢 – user1190937 2012-02-06 09:15:42

0

也许尝试:

$html = htmlspecialchars(file_get_contents('http://stackoverflow.com/questions/ask')); 

并尝试使用标签来输出。

0

只需HTML编码您的输出,以便&变为& amp ;,使用htmlentities函数。

-2

尝试使用EXEC和wget一起:

<?php 

exec('wget http://stackoverflow.com/questions/ask -O', $array); 

echo implode('<br />', $array); 

?> 
-1
$handle = @fopen("'http://www.webmasterworld.com", "rt"); 
$code = fread($handle,9000); 

这是复制形式另一个线程,但它应该是足够了。它将获得$ handle中的代码,然后$ code将包含该代码的9000个字节。