diggin / diggin-http-charset
基于header的charset和html meta charset进行检测。自动转换为UTF-8。
1.0.0
2019-05-06 04:57 UTC
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: ~4.3
- symfony/browser-kit: ~2.4
- zendframework/zend-http: ~2.2
This package is auto-updated.
Last update: 2024-09-06 16:17:48 UTC
README
自动转换为UTF-8。
基于header的charset和html meta charset进行检测。
(处理多个charset更仔细 - SJIS-win, TIS-620等..)
此库旨在用于网络爬虫。
需求
- PHP 5.3或更高版本
- mbstring和iconv
使用方法
- 包装响应对象
<?php use Diggin\Http\Charset\WrapperFactory; $client = new Zend\Http\Client($url); $response = $client->send(); $response = WrapperFactory::factory($response); // then, response getBody() return with converted UTF-8.
请参阅demos/Diggin/Http/Charset中的更多内容。
Guzzle & Goutte
guzzle-plugin-AutoCharsetEncodingPlugin支持与Guzzle3一起使用。
与Behat一起使用的方法 by @MugeSo
技术信息
Diggin_Http_Charset基于HTMLScraping。
许可证
Diggin_Http_Charset受LGPL(GNU Lesser General Public License)许可。
类似库
- perl : HTTP::Response::Encoding
- python : Universal Encoding Detector
待办事项
- 处理非text/html内容类型。
- 更好的API和符合ZF2编码标准。
- 在更多charset上努力 :-\