12345678910111213141516171819202122232425262728293031323334 |
- <?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'));
- $config = array('GB2312', 'GBK', 'EUC-CN', 'CP936');
- if (in_array($encode, $config)) {
- $string = iconv('GBK', 'UTF-8', $string);
- }
- /*
- if ($encode == 'CP936') {
- $string = iconv('SJIS', 'UTF-8', $string);
- }
- */
- $string = str_replace(PHP_EOL, '', $string);
- return $string;
- }
- }
|