| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | 
							- <?php
 
- namespace Spider\Lib;
 
- use Dever;
 
- class Download
 
- {
 
- 	private $data;
 
- 	public function __construct($url, $param)
 
- 	{
 
- 		if (isset($param['request_type']) && $param['request_type'] == 2) {
 
- 			$param['request_type'] = 'post';
 
- 		} else {
 
- 			$param['request_type'] = 'get';
 
- 		}
 
- 		if (isset($param['content_type']) && $param['content_type'] == 2) {
 
- 			$param['content_type'] = true;
 
- 		} else {
 
- 			$param['content_type'] = false;
 
- 		}
 
- 		if (!isset($param['param'])) {
 
- 			$param['param'] = array();
 
- 		}
 
- 		if (!isset($param['header'])) {
 
- 			$param['header'] = false;
 
- 		}
 
- 		$this->data = Dever::curl($url, $param['param'], $param['request_type'], $param['content_type'], $param['header']);
 
- 	}
 
- 	public function get($type)
 
- 	{
 
- 		return $this->filter($this->data, $type);
 
- 	}
 
- 	private function filter($string, $type)
 
- 	{
 
- 		if ($type != 'json') {
 
- 			$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;
 
- 	}
 
- }
 
 
  |