Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f3cbc8b8c | ||
|
|
475c200b67 |
44
README.md
44
README.md
@@ -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);
|
||||||
|
```
|
||||||
@@ -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