From 9416ecc36b48ff0f85a3c9f198ae4cac159f944c Mon Sep 17 00:00:00 2001 From: krzysiej Date: Fri, 6 Apr 2018 13:45:04 +0200 Subject: [PATCH] =?UTF-8?q?Dodanie=20testowej=20strony=20packt.html,=20roz?= =?UTF-8?q?poznanie=20kilku=20dodatkowych=20danych=20o=20ksi=C4=85=C5=BCka?= =?UTF-8?q?ch.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packt.html | 55636 +++++++++++++++++++++++++++++++++++++++++++++++++++ packt.php | 23 +- 2 files changed, 55655 insertions(+), 4 deletions(-) create mode 100644 packt.html diff --git a/packt.html b/packt.html new file mode 100644 index 0000000..540f2ee --- /dev/null +++ b/packt.html @@ -0,0 +1,55636 @@ + + + Packt Publishing | Technology Books, eBooks & Videos + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/packt.php b/packt.php index 392deb8..4019761 100644 --- a/packt.php +++ b/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);