12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace Spider\Lib;
- use Dever;
- class Download
- {
- private $data;
- public function __construct($url)
- {
- $this->data = Dever::curl($url);
- }
- public function get()
- {
- return $this->filter($this->data);
- }
- private function filter($string)
- {
- $encode = mb_detect_encoding($string, array('GB2312','GBK','UTF-8'));
- if ($encode == 'GB2312' || $encode == 'GBK' || $encode == 'EUC-CN') {
- $string = \iconv('GBK', 'UTF-8', $string);
- }
- if ($encode == 'CP936') {
- $string = \iconv('SJIS', 'UTF-8', $string);
- }
- $string = str_replace(PHP_EOL, '', $string);
- return $string;
- }
- }
|