我正在解析一个网站以获取信息。我用php使用curl和xpath。在他的源代码中,他写了
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
在网站的开头。所以我认为他的代码使用iso-8859-1。 我要解析的div是:
<div class="box_title_ficha"><span>50% Dto.</span> Curso on-line de inglés de ABA English por 12,50 € en vez de 24,99 €. ¡Aprende inglés desde cualquier lugar con el método más completo!</div>
我的代码:
$info = trim(strip_tags($xpath->query("//div[@class='box_title_ficha']")->item
(0)->nodeValue)); $info = html_entity_decode($info , ENT_QUOTES, "iso-8859-1");
我使用此指令获取信息。之后,我需要将它保存到mysql数据库中。所以我需要编码。但我没有保存欧元的标志。当我尝试显示这个句子时,符号欧元消失或显示为一个块。 我试过了:
htmlentities($info , ENT_QUOTES, "iso-8859-1"); , mb_convert_encoding($info , "ISO-8859-1");
htmlentities(html_entity_decode(utf8_decode($info )), ENT_QUOTES, "iso-8859-1");
所有 charset of php htmlentites 以及所有形式混合的这些功能。他们都没有工作。 我认为开发人员直接从他的键盘输入了欧元......
以下是我解析的网站的链接:http://www.aprendum.com/curso-ingles-on-line-p44 任何人都有一些建议吗?非常感谢。