Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加完整的编码方式属性,DOMDocument::loadHTML才能正确识别UTF-8 #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ $spider->start();
更多详细内容,移步到:

[开发文档](http://doc.phpspider.org)
Let me try if github account still works.
2 changes: 1 addition & 1 deletion core/requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public static function get_response_body($domain)
// 先将非utf8编码,转化为utf8编码
$body = @mb_convert_encoding($body, self::$output_encoding, self::$input_encoding);
// 将页面中的指定的编码方式修改为utf8
$body = preg_replace("/<meta([^>]*)charset=([^>]*)>/is", '<meta charset="UTF-8">', $body);
$body = preg_replace("/<meta([^>]*)charset=([^>]*)>/is", '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>', $body);
// 直接干掉头部,国外很多信息是在头部的
//$body = self::_remove_head($body);
}
Expand Down