简单 PHP Dom 解析器,用于查找带符号的 HTML ID
Simple PHP Dom Parser to find HTML ID with symbols
我对 PHP 简单 HTML dom 解析器有疑问。
我找到一个带有 ® 符号的 html ID,但 API 无法识别(此 class 存在于 html 文件中)。
?>
header('Content-Type: text/html; charset=UTF-8');
require 'simple_html_dom.php';
$html = file_get_html('http://ark.intel.com/products/88194/Intel-Core-i7-6500U-Processor-4M-Cache-up-to-3_10-GHz');
//There is the problem on the ® symbol.
foreach($html->find('div#infosectionintel®platformprotectiontechnology-scrollpane') as $protection) {
$item8['osguardxx'] = $protection->find('tr#OSGuardTechVersion td.rc', 0)->plaintext;
$item8['txtxxxxxx'] = $protection->find('tr#TXT td.rc', 0)->plaintext;
$item8['exedisbit'] = $protection->find('tr#ExecuteDisable td.rc', 0)->plaintext;
$protections[] = $item8;
}
print_r($protections);
?>
我已经用其他 div# 测试过没有符号并且效果很好!!
谢谢你的帮助!
您可以使用 chr($ascii)
(将 ascii 替换为 ® 的 ascii 代码)或者您可以像这样使用通配符:
foreach($html->find('div[id*=infosectionintel]', 0) as $protection) {
它会查找名称中包含 infosectionintel
的任何 div id。
我对 PHP 简单 HTML dom 解析器有疑问。 我找到一个带有 ® 符号的 html ID,但 API 无法识别(此 class 存在于 html 文件中)。
?>
header('Content-Type: text/html; charset=UTF-8');
require 'simple_html_dom.php';
$html = file_get_html('http://ark.intel.com/products/88194/Intel-Core-i7-6500U-Processor-4M-Cache-up-to-3_10-GHz');
//There is the problem on the ® symbol.
foreach($html->find('div#infosectionintel®platformprotectiontechnology-scrollpane') as $protection) {
$item8['osguardxx'] = $protection->find('tr#OSGuardTechVersion td.rc', 0)->plaintext;
$item8['txtxxxxxx'] = $protection->find('tr#TXT td.rc', 0)->plaintext;
$item8['exedisbit'] = $protection->find('tr#ExecuteDisable td.rc', 0)->plaintext;
$protections[] = $item8;
}
print_r($protections);
?>
我已经用其他 div# 测试过没有符号并且效果很好!! 谢谢你的帮助!
您可以使用 chr($ascii)
(将 ascii 替换为 ® 的 ascii 代码)或者您可以像这样使用通配符:
foreach($html->find('div[id*=infosectionintel]', 0) as $protection) {
它会查找名称中包含 infosectionintel
的任何 div id。