可能重复:
How do I get the HTML code of a web page in PHP?PHP代码来获得一个网页的HTML代码
是否有一个PHP代码来获得一个网页的HTML代码? $ html = file_get_contents('https://stackoverflow.com/questions/ask'); 这不工作。它只是加载网页。我想在运行代码时显示HTML代码。
在此先感谢。
可能重复:
How do I get the HTML code of a web page in PHP?PHP代码来获得一个网页的HTML代码
是否有一个PHP代码来获得一个网页的HTML代码? $ html = file_get_contents('https://stackoverflow.com/questions/ask'); 这不工作。它只是加载网页。我想在运行代码时显示HTML代码。
在此先感谢。
尝试:
echo htmlentities(file_get_contents('http://stackoverflow.com/questions/ask'));
非常感谢。此代码适用于给定的网址。但它不适用于'http://www.maduraonline.com/?find=home'。它只是显示网页。任何想法为什么这是?我想要这个网页的HTML代码,因为我正在开发一个翻译。我能做些什么来获得它的HTML代码? 非常感谢 – user1190937 2012-02-06 09:15:42
也许尝试:
$html = htmlspecialchars(file_get_contents('http://stackoverflow.com/questions/ask'));
并尝试使用标签来输出。
只需HTML编码您的输出,以便&变为& amp ;,使用htmlentities函数。
尝试使用EXEC和wget一起:
<?php
exec('wget http://stackoverflow.com/questions/ask -O', $array);
echo implode('<br />', $array);
?>
$handle = @fopen("'http://www.webmasterworld.com", "rt");
$code = fread($handle,9000);
这是复制形式另一个线程,但它应该是足够了。它将获得$ handle中的代码,然后$ code将包含该代码的9000个字节。
然后不要查看浏览器中的输出。或发送文本标题。 – Gordon 2012-02-05 18:16:58