From 8c5ae22081fc497d1a46fdc40c3679e19bbf29fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20P=C5=82aczek?= Date: Thu, 2 Oct 2025 12:44:04 +0200 Subject: [PATCH] Add translator --- src/Api/AbstractBookInfo.php | 1 + src/DataParser.php | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Api/AbstractBookInfo.php b/src/Api/AbstractBookInfo.php index 54ecf7a..bf07c07 100644 --- a/src/Api/AbstractBookInfo.php +++ b/src/Api/AbstractBookInfo.php @@ -18,4 +18,5 @@ abstract class AbstractBookInfo public ?string $language; public string $datePublished; public ?string $publisher; + public ?string $translator; } \ No newline at end of file diff --git a/src/DataParser.php b/src/DataParser.php index 8e7f8d3..7417896 100644 --- a/src/DataParser.php +++ b/src/DataParser.php @@ -4,6 +4,7 @@ namespace Techtube\Bookinfo; use DiDom\Document; use DiDom\Exceptions\InvalidSelectorException; +use DiDom\Query; use JetBrains\PhpStorm\ArrayShape; use Techtube\Bookinfo\Api\AbstractBookInfo; @@ -35,6 +36,7 @@ class DataParser } $info->language = $jsonInfo?->inLanguage ?? trim($document->xpath("//*[contains(text(), 'Język:')]")[0]->nextSibling('dd')->text()); $info->datePublished = $jsonInfo?->datePublished ?? null; + $info->translator = trim($document->first("//*[contains(text(), 'Tłumacz:')]", Query::TYPE_XPATH)?->nextSibling('dd')?->text() ?? ''); return $info; } @@ -47,9 +49,6 @@ class DataParser public function searchPage(Document $document): array { $books = $document->find('#ksiazki .authorAllBooks__single'); - //https://lubimyczytac.pl/searcher/getNextResults/ksiazki - //echo $document->html(); - print_r($books); $booksInfo = []; if ($document->has('#searchksiazki')) { foreach ($books as $book) {