Archived
1
0
Fork 0

Apero fixes

This commit is contained in:
Alexander Yakovlev 2018-07-20 12:38:23 +07:00
parent 6a3c912940
commit 41be2895b2
2 changed files with 17 additions and 6 deletions

View file

@ -83,13 +83,20 @@ abstract class Source {
*
* @return string
*/
public function get_text($url) {
public function get_text($url, $post = []) {
$client = new GuzzleClient([
'timeout' => 30,
]);
$response = $client->request('GET', $url, [
'cookies' => $this->cookies,
]);
if ($post === []) {
$response = $client->request('GET', $url, [
'cookies' => $this->cookies,
]);
} else {
$response = $client->request('POST', $url, [
'form_params' => $post,
'cookies' => $this->cookies,
]);
}
return (string) $response->getBody();
}

View file

@ -27,11 +27,15 @@ use \Game;
class Apero extends Source {
public $title = "Apero";
protected function parse() {
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница');
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница', [
'order_by' => 'by_public',
]);
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
$this->loadStr($text);
$this->parseIndex();
$text = $this->get_text('http://apero.ru/Текстовые-игры');
$text = $this->get_text('http://apero.ru/Текстовые-игры', [
'order_by' => 'by_public',
]);
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
$this->loadStr($text);
$this->parseIndex();