Update search to website changes #1

Merged
krzysiej merged 4 commits from feature/update-to-website-changes into master 2025-10-03 15:21:57 +02:00
2 changed files with 3 additions and 3 deletions
Showing only changes of commit 8c5ae22081 - Show all commits

View File

@@ -18,4 +18,5 @@ abstract class AbstractBookInfo
public ?string $language; public ?string $language;
public string $datePublished; public string $datePublished;
public ?string $publisher; public ?string $publisher;
public ?string $translator;
} }

View File

@@ -4,6 +4,7 @@ namespace Techtube\Bookinfo;
use DiDom\Document; use DiDom\Document;
use DiDom\Exceptions\InvalidSelectorException; use DiDom\Exceptions\InvalidSelectorException;
use DiDom\Query;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use Techtube\Bookinfo\Api\AbstractBookInfo; 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->language = $jsonInfo?->inLanguage ?? trim($document->xpath("//*[contains(text(), 'Język:')]")[0]->nextSibling('dd')->text());
$info->datePublished = $jsonInfo?->datePublished ?? null; $info->datePublished = $jsonInfo?->datePublished ?? null;
$info->translator = trim($document->first("//*[contains(text(), 'Tłumacz:')]", Query::TYPE_XPATH)?->nextSibling('dd')?->text() ?? '');
return $info; return $info;
} }
@@ -47,9 +49,6 @@ class DataParser
public function searchPage(Document $document): array public function searchPage(Document $document): array
{ {
$books = $document->find('#ksiazki .authorAllBooks__single'); $books = $document->find('#ksiazki .authorAllBooks__single');
//https://lubimyczytac.pl/searcher/getNextResults/ksiazki
//echo $document->html();
print_r($books);
$booksInfo = []; $booksInfo = [];
if ($document->has('#searchksiazki')) { if ($document->has('#searchksiazki')) {
foreach ($books as $book) { foreach ($books as $book) {