Compare commits
4 Commits
master
...
feature/up
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
171c050368 | ||
|
|
e8081cd898 | ||
|
|
8c5ae22081 | ||
|
|
406d6a8f8d |
@@ -10,7 +10,13 @@ Place this in the composer.json.
|
||||
}]
|
||||
}
|
||||
```
|
||||
Then execute
|
||||
Then execute to get latest version:
|
||||
|
||||
```bash
|
||||
composer require techtube/bookinfo
|
||||
```
|
||||
|
||||
or this to get specific version:
|
||||
|
||||
```bash
|
||||
composer require techtube/bookinfo:"1.0.4"
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "kplaczek",
|
||||
"email": "kplaczek@wi.ps.pl"
|
||||
"name": "Krzysztof Płaczek",
|
||||
"email": "krzysztofplaczek@techtube.pl"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,12 +9,15 @@ abstract class AbstractBookInfo
|
||||
public string $isbn;
|
||||
public string $description;
|
||||
public string $title;
|
||||
public string $originalTitle;
|
||||
public string $category;
|
||||
public array $cover_url;
|
||||
public int $pages;
|
||||
public string $cycle;
|
||||
public int $volume;
|
||||
public string $cycleUrl;
|
||||
public string $volume;
|
||||
public ?string $language;
|
||||
public string $datePublished;
|
||||
public ?string $publisher;
|
||||
public ?string $translator;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class BookFinder
|
||||
|
||||
private function getSearchUrl(string $phrase): string
|
||||
{
|
||||
return self::$searchUrl . $phrase;
|
||||
return sprintf('%s%s', self::$searchUrl, $phrase);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Techtube\Bookinfo;
|
||||
|
||||
use DiDom\Document;
|
||||
use DiDom\Exceptions\InvalidSelectorException;
|
||||
use DiDom\Query;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use Techtube\Bookinfo\Api\AbstractBookInfo;
|
||||
|
||||
@@ -24,6 +25,7 @@ class DataParser
|
||||
$info->isbn = $document->first('meta[property="books:isbn"]')->getAttribute('content');
|
||||
$info->description = trim($document->first('#book-description p')->text());
|
||||
$info->title = trim($document->first('h1.book__title')->text());
|
||||
$info->originalTitle = trim($document->first("//*[contains(text(), 'Tytuł oryginału:')]", Query::TYPE_XPATH)?->nextSibling('dd')?->text() ?? '');
|
||||
$info->category = trim($document->first('.book__category')->text());
|
||||
$info->cover_url = $this->generateCoverUrls(
|
||||
$document->first('meta[property="og:image"]')->getAttribute('content')
|
||||
@@ -35,6 +37,7 @@ class DataParser
|
||||
}
|
||||
$info->language = $jsonInfo?->inLanguage ?? trim($document->xpath("//*[contains(text(), 'Język:')]")[0]->nextSibling('dd')->text());
|
||||
$info->datePublished = $jsonInfo?->datePublished ?? null;
|
||||
$info->translator = trim($document->first("//*[contains(text(), 'Tłumacz:')]", Query::TYPE_XPATH)?->nextSibling('dd')?->text() ?? '');
|
||||
|
||||
return $info;
|
||||
}
|
||||
@@ -46,8 +49,7 @@ class DataParser
|
||||
*/
|
||||
public function searchPage(Document $document): array
|
||||
{
|
||||
$books = $document->find('#search .authorAllBooks__single');
|
||||
|
||||
$books = $document->find('#ksiazki .authorAllBooks__single');
|
||||
$booksInfo = [];
|
||||
if ($document->has('#searchksiazki')) {
|
||||
foreach ($books as $book) {
|
||||
@@ -56,6 +58,11 @@ class DataParser
|
||||
$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'));
|
||||
if (preg_match('#(.*) \(tom (.*)\)#ism', trim($book->first('a[href*="/cykl/"]')?->text() ?? ''), $series)) {
|
||||
$bookInfo->cycle = $series[1];
|
||||
$bookInfo->volume = $series[2];
|
||||
$bookInfo->cycleUrl = $book->first('a[href*="/cykl/"]')?->href;
|
||||
}
|
||||
$booksInfo[] = $bookInfo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user