你能用#34; php简单的html dom"拿一块HTML而不仅仅是内容?
我和他一起:
foreach ($html->find('div.info-bar') as $infop) {
$info = $infop->plaintext;
}
不幸的是,输出是:
24级奖杯4201铜牌2725银1057金牌341白金78 等级24 66 66%
虽然我想提取纯HTML ..
这是我的代码:
include('simple_html_dom.php');
$html = file_get_html('https://my.playstation.com/obaidmiz04');
foreach ($html->find('div.info-bar') as $infop) {
$info = $infop->plaintext;
}
echo $info;
答案 0 :(得分:1)
$escapedHtmlChars = "";
$htmlElements = "";
$html = file_get_html('https://my.playstation.com/obaidmiz04');
foreach ($html->find('div.info-bar') as $infop) {
//You can see html characters in text
//This shows you html codes, not for using
$escapedHtmlChars .= htmlspecialchars($infop);
//You can see html elements
$htmlElements .= $infop;
//You can see only text in selected element
$plainText .= $infop->plaintext;
}
echo $plainText;
echo "<br /> <br />";
echo $escapedHtmlChars;
echo "<br /> <br />";
echo $htmlElements;
纯文本方法仅返回所选元素中的文本。