Dodanie testowej strony packt.html, rozpoznanie kilku dodatkowych danych o książkach.

This commit is contained in:
krzysiej
2018-04-06 13:45:04 +02:00
parent a6423de806
commit 9416ecc36b
2 changed files with 55655 additions and 4 deletions

55636
packt.html Normal file

File diff suppressed because one or more lines are too long

View File

@@ -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);