使用 PHP 简单 HTML DOM 解析器提取 HTML 纯

Extract HTML pure with PHP Simple HTML DOM Parser

你能和 "php simple html dom" 一起拿一块 HTML 而不仅仅是内容吗?

我试过:

foreach ($html->find('div.info-bar') as $infop) {
  $info = $infop->plaintext;
}

不幸的是,输出是:

Level 24 Trophies 4201 Bronze 2725 Silver 1057 Gold 341 Platinum 78 Level 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;
$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;

纯文本方法 returns 所选元素中的唯一文本。