【发布时间】:2024-01-23 08:50:01
【问题描述】:
我已经使用file_get_contents 函数创建了我的爬虫,但是当我爬取一些网站时,我得到了这个字符:� 当我应该得到这个时:é。关于正在发生的事情的一些想法?
这适用于运行 php 的 windows vps 服务器。
我已经试过了:
但是所有这些都不起作用。
PD:我运行此代码的文件是 UTF8。
$url = "https://play.google.com/books/reader?id=4rqYDwAAQBAJ&hl=en_US";
$options = array('http'=>array('method'=>"GET", 'header'=>"Accept-language: en-US,en;q=0.8\r\n" ."Accept-Charset: UTF-8, *;q=0"));
$context = stream_context_create($options)
$profile = file_get_contents($url,false,$context);
echo $profile
我希望得到重音字符,而不是这个菱形字符。
【问题讨论】:
-
如果你读的问题不一样!
-
您的 php 文件保存为什么格式?确实如此。
-
全部为 UTF8 编码 @FunkFortyNiner
-
好的。但 UTF8 有 2 种另存为的方法。有或没有 BOM(字节顺序标记)可能会有所不同。
-
无 BOM。 @FunkFortyNiner
标签: php html file character-encoding file-get-contents