Dodanie testowej strony packt.html, rozpoznanie kilku dodatkowych danych o książkach.
This commit is contained in:
55636
packt.html
Normal file
55636
packt.html
Normal file
File diff suppressed because one or more lines are too long
23
packt.php
23
packt.php
@@ -44,15 +44,30 @@ function c($url, $post = [])
|
||||
}
|
||||
|
||||
|
||||
$return = c('https://www.packtpub.com/', $loginData);
|
||||
$return = c('https://www.packtpub.com/account/my-ebooks');
|
||||
//$return = c('https://www.packtpub.com/', $loginData);
|
||||
//$return = c('https://www.packtpub.com/account/my-ebooks');
|
||||
//var_dump($return);
|
||||
$document = new Document($return);
|
||||
//var_dump($return);
|
||||
//$document = new Document($return);
|
||||
|
||||
$document = new Document('packt.html', true);
|
||||
|
||||
$booksData = [];
|
||||
$books = $document->find('.product-line.unseen');
|
||||
foreach ($books as $book) {
|
||||
$booksData[] = trim($book->first('.title::text'));
|
||||
|
||||
// print_r($book->html());
|
||||
$bookData = [];
|
||||
$bookData['title'] = str_replace(["\r\n"], '', trim($book->first('.title::text')));
|
||||
$bookData['nid'] = (int)$book->attr('nid');
|
||||
|
||||
$bookData['pdf'] = $book->first('a[href$=pdf]::attr(href)');
|
||||
$bookData['epub'] = $book->first('a[href$=epub]::attr(href)');
|
||||
$bookData['mobi'] = $book->first('a[href$=mobi]::attr(href)');
|
||||
$bookData['code'] = $book->first('a[href*=code_download]::attr(href)');
|
||||
|
||||
$booksData[] = $bookData;
|
||||
|
||||
}
|
||||
print_r($booksData);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user