diff --git a/src/DataParser.php b/src/DataParser.php index 53d92a9..189113d 100644 --- a/src/DataParser.php +++ b/src/DataParser.php @@ -49,13 +49,15 @@ class DataParser $books = $document->find('#search .authorAllBooks__single'); $booksInfo = []; - foreach ($books as $book) { - $bookInfo = new Info(); - $bookInfo->title = trim($book->first('.authorAllBooks__singleTextTitle')->text()); - $bookInfo->author = trim($book->first('.authorAllBooks__singleTextAuthor')->text()); - $bookInfo->url = $book->first('button[data-book-url]')->getAttribute('data-book-url'); - $bookInfo->cover_url = $this->generateCoverUrls($book->first('.img-fluid')->getAttribute('data-src')); - $booksInfo[] = $bookInfo; + if ($document->has('#searchksiazki')) { + foreach ($books as $book) { + $bookInfo = new Info(); + $bookInfo->title = trim($book->first('.authorAllBooks__singleTextTitle')->text()); + $bookInfo->author = trim($book->first('.authorAllBooks__singleTextAuthor')->text()); + $bookInfo->url = $book->first('button[data-book-url]')->getAttribute('data-book-url'); + $bookInfo->cover_url = $this->generateCoverUrls($book->first('.img-fluid')->getAttribute('data-src')); + $booksInfo[] = $bookInfo; + } } return $booksInfo; }