Посетитель
![](./im/images/pips4.gif)
Покинул форум
Сообщений всего: 327
Дата рег-ции: Окт. 2010
Помог: 1 раз(а)
![](./templates/InvisionExBB/im/spacer.gif)
|
Коллеги, приветствую!
Возможно кто-то знает пути решения проблемы связанной с CURL и сайтом без UTF8.
Использую следующий класс для парсера нужной страницы
PHP:
скопировать код в буфер обмена
class BotLib { var $curl; /* * CURL options for session */ var $userAgent; var $contentEncoding; var $connectTimeout; var $followLocation; var $returnTransfer; var $cookieFile; var $cookieSession; public function __construct() { $this->_crash("Can't initialize CURL library!"); } } public function setCurlOptions($userAgent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13', $contentEncoding = 'gzip,deflate', $connectTimeout = 100, $followLocation = true, $returnTransfer = true, $cookieFile = 'cookiefile', $cookieSession = true) { $this->userAgent = $userAgent; $this->contentEncoding = $contentEncoding; $this->connectTimeout = $connectTimeout; $this->followLocation = $followLocation; $this->returnTransfer = $returnTransfer; $this->cookieFile = $cookieFile; $this->cookieSession = $cookieSession; } public function _getRequest($url) { curl_setopt($this->curl, CURLOPT_COOKIESESSION , $this->cookieSession); curl_setopt($this->curl, CURLOPT_COOKIEFILE , $this->cookieFile); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER , $this->returnTransfer); curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION , $this->followLocation); curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT , $this->connectTimeout); curl_setopt($this->curl, CURLOPT_ENCODING , $this->contentEncoding); curl_setopt($this->curl, CURLOPT_USERAGENT , $this->userAgent); return $a; } else { return false; } } public function _postRequest($url, $params) { curl_setopt($this->curl, CURLOPT_USERAGENT , $this->userAgent); curl_setopt($this->curl, CURLOPT_COOKIESESSION , $this->cookieSession); curl_setopt($this->curl, CURLOPT_COOKIEFILE , $this->cookieFile); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER , $this->returnTransfer); curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION , $this->followLocation); curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT , $this->connectTimeout); curl_setopt($this->curl, CURLOPT_ENCODING , $this->contentEncoding); return $a; } else { return false; } } }
Это довольно старый и распространенный скрипт в интернете. Страничку с UTF-8 он забирает без проблем, но если кодировка win-1251, то символы становятся не понятными. Как можно решить проблемку?
|