Working multi-account html grabber
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/*****************************************************************
|
||||
Пример использования:
|
||||
|
||||
$vk_parser = new Vkontakte();
|
||||
$vk_parser = new Vkontakte($bot_name);
|
||||
$vk_parser->parse('Blondie - Call Me');
|
||||
$files = $vk_parser->getFiles();
|
||||
*****************************************************************/
|
||||
@@ -22,6 +22,12 @@ class Vkontakte {
|
||||
private $_html; // HTML, полученый от вконтактика
|
||||
private $_files; // Распарсеные массивы с информацией о файле
|
||||
|
||||
private $_bot_info; // Информация о боте
|
||||
|
||||
public function __construct($bot_name) {
|
||||
$this->_bot_info = Config::get('bot:'. $bot_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Оболочка парсера
|
||||
*
|
||||
@@ -29,7 +35,7 @@ class Vkontakte {
|
||||
* @return array Массив с файлами
|
||||
* @author chez
|
||||
**/
|
||||
public function parse($q) {
|
||||
public function getTracks($q) {
|
||||
$this->_query = $q;
|
||||
$this->auth();
|
||||
$cookie = array();
|
||||
@@ -42,18 +48,20 @@ class Vkontakte {
|
||||
'X-Requested-With: XMLHttpRequest',
|
||||
'Origin: http://vkontakte.ru',
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16',
|
||||
'User-Agent: '. $this->_bot_info['user_agent'],
|
||||
'Connection: close'
|
||||
));
|
||||
$this->setHtml(RemoteFile::getData('http://vkontakte.ru/audio', array(
|
||||
'act' =>'search',
|
||||
'al' =>'1',
|
||||
'gid' =>'0',
|
||||
'id' =>'5728795',
|
||||
'offset' =>'0',
|
||||
$html = RemoteFile::getData('http://vkontakte.ru/audio', array(
|
||||
'act' => 'search',
|
||||
'al' => '1',
|
||||
'gid' => '0',
|
||||
'id' => $this->_bot_info['user_id'],
|
||||
'offset' => '0',
|
||||
'q' => urlencode($this->_query),
|
||||
'sort' =>'2'
|
||||
)));
|
||||
'sort' => '2'
|
||||
));
|
||||
$this->setHtml($html);
|
||||
return (strlen($html) > 150);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,8 +104,8 @@ class Vkontakte {
|
||||
**/
|
||||
private function auth() {
|
||||
$this->_cookies = array(
|
||||
'remixchk' => 5,
|
||||
'remixsid' => 'cf8bdd79d451422c1d484532a58205d92fc46b79caab663a40624c812e01',
|
||||
'remixchk' => $this->_bot_info['remixchk'],
|
||||
'remixsid' => $this->_bot_info['remixsid'],
|
||||
'remixlang' => 777
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,9 @@ class BeatDB {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return (bool) file_put_contents($part . $path[$i], json_encode($data));
|
||||
file_put_contents($part . $path[$i], json_encode($data));
|
||||
chmod($part . $path[$i], 0777);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function delete($key) {
|
||||
|
||||
Reference in New Issue
Block a user