我在网站目标中找到了这样的代码
http://lufy.byethost6.com/tes.html
并使用这些代码来解析它
<?php
include('simple_html_dom.php');
$html = new simple_html_dom();
$html = file_get_html('http://lufy.byethost6.com/tes.html');
$ret = $html->find('pre',0);
echo $ret;
?>当我看到结果时,它变成了这样的一行
title goes here Intro : Gm Cm Gm Cm Gm Cm lyrics, lyrics, lyrics, lyrics, lyrics, lyrics, Gm Cm lyrics, lyrics, lyrics, lyrics, lyrics, lyrics 我希望结果和目标站点看起来一样
title goes here
Intro : Gm Cm
Gm Cm
Gm Cm
lyrics, lyrics, lyrics, lyrics, lyrics, lyrics,
Gm Cm
lyrics, lyrics, lyrics, lyrics, lyrics, lyrics有可能吗?
发布于 2014-08-27 02:27:38
您需要将标志$stripRN设置为false,因为默认情况下,换行标记将被去掉。改为:
$html = file_get_html('http://lufy.byethost6.com/tes.html', $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=false, $defaultBRText=DEFAULT_BR_TEXT);发布于 2014-08-27 02:27:29
我觉得你需要用
echo $ret->outertext;请参阅api.htm
https://stackoverflow.com/questions/25517946
复制相似问题