Book authors, bio, table of content and what will learn section.
This commit is contained in:
12
packt.php
12
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user