Before running parse operation on search results page it checks now if there are any books to parse.
This commit is contained in:
@@ -49,13 +49,15 @@ class DataParser
|
|||||||
$books = $document->find('#search .authorAllBooks__single');
|
$books = $document->find('#search .authorAllBooks__single');
|
||||||
|
|
||||||
$booksInfo = [];
|
$booksInfo = [];
|
||||||
foreach ($books as $book) {
|
if ($document->has('#searchksiazki')) {
|
||||||
$bookInfo = new Info();
|
foreach ($books as $book) {
|
||||||
$bookInfo->title = trim($book->first('.authorAllBooks__singleTextTitle')->text());
|
$bookInfo = new Info();
|
||||||
$bookInfo->author = trim($book->first('.authorAllBooks__singleTextAuthor')->text());
|
$bookInfo->title = trim($book->first('.authorAllBooks__singleTextTitle')->text());
|
||||||
$bookInfo->url = $book->first('button[data-book-url]')->getAttribute('data-book-url');
|
$bookInfo->author = trim($book->first('.authorAllBooks__singleTextAuthor')->text());
|
||||||
$bookInfo->cover_url = $this->generateCoverUrls($book->first('.img-fluid')->getAttribute('data-src'));
|
$bookInfo->url = $book->first('button[data-book-url]')->getAttribute('data-book-url');
|
||||||
$booksInfo[] = $bookInfo;
|
$bookInfo->cover_url = $this->generateCoverUrls($book->first('.img-fluid')->getAttribute('data-src'));
|
||||||
|
$booksInfo[] = $bookInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $booksInfo;
|
return $booksInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user