Archived
1
0
Fork 0

Фикс для сломанного Аперо

This commit is contained in:
Alexander Yakovlev 2018-02-16 12:46:45 +07:00
parent 820def53a9
commit 17137bb261
2 changed files with 127 additions and 75 deletions

View file

@ -3,13 +3,25 @@ namespace Source;
use \Game;
/**
* Парсер для Apero.ru
* Проблема парсера в том, что на Аперо часто поломана кодировка UTF-8.
*/
class Apero extends Source {
public $title = "Apero";
protected function parse() {
$formatter = new \IntlDateFormatter( 'ru', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE );
$text = $this->get_text('https://apero.ru/');
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница');
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
$this->dom->loadStr($text, []);
unset($text);
$this->parsePage();
$text = $this->get_text('http://apero.ru/Текстовые-игры');
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
$this->dom->loadStr($text, []);
$this->parsePage();
}
protected function parsePage()
{
$formatter = new \IntlDateFormatter( 'ru', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE );
$games = $this->dom->find('.tabled-game-block');
foreach ($games as $gameBlock) {
$date = trim($gameBlock->find('.game-updated-block')->innerHtml, "() \t\n\r\0\x0B");

184
composer.lock generated
View file

@ -4,8 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "a296a064ac4a9d46aa92547a70fee2f8",
"content-hash": "dc702cd7ccff8e6628862101848de338",
"content-hash": "c9715035ce158bfa729e665ae0b87544",
"packages": [
{
"name": "aura/autoload",
@ -54,7 +53,7 @@
"autoloader",
"class loader"
],
"time": "2016-10-03 19:36:19"
"time": "2016-10-03T19:36:19+00:00"
},
{
"name": "league/html-to-markdown",
@ -118,7 +117,41 @@
"html",
"markdown"
],
"time": "2017-03-16 00:45:59"
"time": "2017-03-16T00:45:59+00:00"
},
{
"name": "neitanod/forceutf8",
"version": "v2.0.1",
"source": {
"type": "git",
"url": "https://github.com/neitanod/forceutf8.git",
"reference": "47c883ab2739e7938a8bb0bfd1c29d48c88858de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/neitanod/forceutf8/zipball/47c883ab2739e7938a8bb0bfd1c29d48c88858de",
"reference": "47c883ab2739e7938a8bb0bfd1c29d48c88858de",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"ForceUTF8\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"authors": [
{
"name": "Sebastián Grignoli",
"email": "grignoli@gmail.com"
}
],
"description": "PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.",
"homepage": "https://github.com/neitanod/forceutf8",
"time": "2017-05-22T18:50:57+00:00"
},
{
"name": "paquettg/php-html-parser",
@ -167,7 +200,7 @@
"html",
"parser"
],
"time": "2016-04-06 15:24:40"
"time": "2016-04-06T15:24:40+00:00"
},
{
"name": "paquettg/string-encode",
@ -213,7 +246,66 @@
"encoding",
"string"
],
"time": "2014-05-29 18:38:09"
"time": "2014-05-29T18:38:09+00:00"
},
{
"name": "patchwork/utf8",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/tchwork/utf8.git",
"reference": "30ec6451aec7d2536f0af8fe535f70c764f2c47a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tchwork/utf8/zipball/30ec6451aec7d2536f0af8fe535f70c764f2c47a",
"reference": "30ec6451aec7d2536f0af8fe535f70c764f2c47a",
"shasum": ""
},
"require": {
"lib-pcre": ">=7.3",
"php": ">=5.3.0"
},
"suggest": {
"ext-iconv": "Use iconv for best performance",
"ext-intl": "Use Intl for best performance",
"ext-mbstring": "Use Mbstring for best performance",
"ext-wfio": "Use WFIO for UTF-8 filesystem access on Windows"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"psr-4": {
"Patchwork\\": "src/Patchwork/"
},
"classmap": [
"src/Normalizer.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"(Apache-2.0 or GPL-2.0)"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
}
],
"description": "Portable and performant UTF-8, Unicode and Grapheme Clusters for PHP",
"homepage": "https://github.com/tchwork/utf8",
"keywords": [
"grapheme",
"i18n",
"unicode",
"utf-8",
"utf8"
],
"time": "2016-05-18T13:57:10+00:00"
},
{
"name": "psr/log",
@ -260,19 +352,19 @@
"psr",
"psr-3"
],
"time": "2016-10-10 12:19:37"
"time": "2016-10-10T12:19:37+00:00"
},
{
"name": "sabre/uri",
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://github.com/fruux/sabre-uri.git",
"url": "https://github.com/sabre-io/uri.git",
"reference": "a42126042c7dcb53e2978dadb6d22574d1359b4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fruux/sabre-uri/zipball/a42126042c7dcb53e2978dadb6d22574d1359b4c",
"url": "https://api.github.com/repos/sabre-io/uri/zipball/a42126042c7dcb53e2978dadb6d22574d1359b4c",
"reference": "a42126042c7dcb53e2978dadb6d22574d1359b4c",
"shasum": ""
},
@ -311,19 +403,19 @@
"uri",
"url"
],
"time": "2017-02-20 20:02:35"
"time": "2017-02-20T20:02:35+00:00"
},
{
"name": "sabre/xml",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/fruux/sabre-xml.git",
"url": "https://github.com/sabre-io/xml.git",
"reference": "054292959a1f2b64c10c9c7a03a816ba1872b8a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fruux/sabre-xml/zipball/054292959a1f2b64c10c9c7a03a816ba1872b8a3",
"url": "https://api.github.com/repos/sabre-io/xml/zipball/054292959a1f2b64c10c9c7a03a816ba1872b8a3",
"reference": "054292959a1f2b64c10c9c7a03a816ba1872b8a3",
"shasum": ""
},
@ -374,7 +466,7 @@
"dom",
"xml"
],
"time": "2016-11-16 00:41:01"
"time": "2016-11-16T00:41:01+00:00"
},
{
"name": "symfony/console",
@ -443,7 +535,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-07-29 21:27:59"
"time": "2017-07-29T21:27:59+00:00"
},
{
"name": "symfony/debug",
@ -499,7 +591,7 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2017-07-28 15:27:31"
"time": "2017-07-28T15:27:31+00:00"
},
{
"name": "symfony/event-dispatcher",
@ -562,7 +654,7 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2017-06-09 14:53:08"
"time": "2017-06-09T14:53:08+00:00"
},
{
"name": "symfony/polyfill-mbstring",
@ -621,7 +713,7 @@
"portable",
"shim"
],
"time": "2017-06-14 15:44:48"
"time": "2017-06-14T15:44:48+00:00"
},
{
"name": "symfony/process",
@ -670,7 +762,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-07-13 13:05:09"
"time": "2017-07-13T13:05:09+00:00"
},
{
"name": "webmozart/assert",
@ -720,65 +812,13 @@
"check",
"validate"
],
"time": "2016-11-23 20:04:58"
},
{
"name": "webmozart/console",
"version": "1.0.0-beta5",
"source": {
"type": "git",
"url": "https://github.com/webmozart/console.git",
"reference": "be58c622090e61a2a7c3ad77baae776b46e7f305"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/console/zipball/be58c622090e61a2a7c3ad77baae776b46e7f305",
"reference": "be58c622090e61a2a7c3ad77baae776b46e7f305",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"symfony/console": "^2.7|^3.0",
"symfony/event-dispatcher": "^2.5|^3.0",
"symfony/process": "^2.5|^3.0",
"webmozart/assert": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1",
"symfony/filesystem": "^2.3|^3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\Console\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "A usable, beautiful and easily testable console toolkit written in PHP.",
"time": "2016-02-05 10:03:13"
"time": "2016-11-23T20:04:58+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"webmozart/console": 10
},
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],