Update search to website changes #1
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user