2 Commits
1.0.3 ... 1.0.5

2 changed files with 53 additions and 7 deletions

View File

@@ -0,0 +1,44 @@
## Installation
Place this in the composer.json.
```composer
{
"repositories": [{
"type": "composer",
"url": "https://satis.techtube.pl"
}]
}
```
Then execute
```bash
composer require techtube/bookinfo:"1.0.4"
```
## Usage
To get information about the book by the link:
```php
<?php
include_once 'vendor/autoload.php';
$searcher = new \Techtube\Bookinfo\BookFinder();
$data = $searcher->byUrl('https://lubimyczytac.pl/ksiazka/5008411/oni');
print_r($data);
```
To search the book by phrase:
```php
<?php
include_once 'vendor/autoload.php';
$searcher = new \Techtube\Bookinfo\BookFinder();
$data = $searcher->search('jack reacher');
print_r($data);
```

View File

@@ -49,6 +49,7 @@ class DataParser
$books = $document->find('#search .authorAllBooks__single'); $books = $document->find('#search .authorAllBooks__single');
$booksInfo = []; $booksInfo = [];
if ($document->has('#searchksiazki')) {
foreach ($books as $book) { foreach ($books as $book) {
$bookInfo = new Info(); $bookInfo = new Info();
$bookInfo->title = trim($book->first('.authorAllBooks__singleTextTitle')->text()); $bookInfo->title = trim($book->first('.authorAllBooks__singleTextTitle')->text());
@@ -57,6 +58,7 @@ class DataParser
$bookInfo->cover_url = $this->generateCoverUrls($book->first('.img-fluid')->getAttribute('data-src')); $bookInfo->cover_url = $this->generateCoverUrls($book->first('.img-fluid')->getAttribute('data-src'));
$booksInfo[] = $bookInfo; $booksInfo[] = $bookInfo;
} }
}
return $booksInfo; return $booksInfo;
} }