只获得代码和不完整的web使用PHP curl在WP


Get only code and not complete web using PHP curl in WP?

我有这个简单的代码:

$theBody = wp_remote_retrieve_body( wp_remote_get('http://www.wordpress.org') );
print_r( $theBody );
die();

它正在工作,但它不只是回显源代码,而是像iframe一样显示页面。

我想我需要告诉我的脚本,我需要显示它作为一个代码,而不是生成页面。

怎么做?

如果你想获取一个网站的任何源代码,那么你可以看看PHP简单的HTML DOM解析器,这是非常容易在这种情况下使用。例子:

include('parsar.php'); // you will get from that website
$html = file_get_html('http://www.google.com/');
echo $html;