diff --git a/packt.php b/packt.php index f5afd41..5c2c13b 100644 --- a/packt.php +++ b/packt.php @@ -50,7 +50,6 @@ function getBookInfo($bookUrl) // $bookPage = c($bookUrl); $bookData = []; $bookPage = new Document($bookUrl, true); - $bookData['authors'] = $bookPage->find('.book-top-block-info-authors::text'); $bookData['datepublished'] = $bookPage->first('.book-top-block-info-authors')->first('time[itemprop="datePublished"]::attr(datetime)'); $bookData['numberofpages'] = $bookPage->first('span[itemprop="numberOfPages"]::text'); $bookData['isbn'] = $bookPage->first('span[itemprop="isbn"]::text'); @@ -68,6 +67,17 @@ function getBookInfo($bookUrl) } } + $bookData['description'] = $bookPage->first('div.book-info-bottom-indetail-text[itemprop="description"]')->find('p::text'); + $bookData['willLearn'] = $bookPage->first('div.book-info-will-learn-text')->find('li::text'); + + $bookData['authors'] = []; + foreach ($bookPage->find('[itemprop="author"]') as $author) { + $authorData = []; + $authorData['name'] = $author->first('h3::text'); + $authorData['bio'] = $author->find('p::text'); + $bookData['authors'][] = $authorData; + } + return $bookData; }