diff options
author | Marvin Borner | 2018-06-18 22:06:04 +0200 |
---|---|---|
committer | Marvin Borner | 2018-06-18 22:06:04 +0200 |
commit | 00bcaead3b61ab4f637c562a63e11e91d3b7852e (patch) | |
tree | a6fe83baf20584d758e36ac37eb0425346147d39 /assets/php | |
parent | 0e0d074f5f3ef3bc0917e4dba9eb408f63014966 (diff) |
Added multiple page crawling
Diffstat (limited to 'assets/php')
-rw-r--r-- | assets/php/getJson.php | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/assets/php/getJson.php b/assets/php/getJson.php index f4155e3..b72070a 100644 --- a/assets/php/getJson.php +++ b/assets/php/getJson.php @@ -1,11 +1,27 @@ <?php $NetflixCookie = $_POST["Cookie"]; -$ch = curl_init("https://www.netflix.com/api/shakti/7742b8c7/viewingactivity"); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); -curl_setopt($ch, CURLOPT_HEADER, 0); -curl_setopt($ch, CURLOPT_COOKIE, $NetflixCookie); -$NetflixJson = curl_exec($ch); -curl_close($ch); - -print_r($NetflixJson);
\ No newline at end of file +$LastPage = FALSE; +$CurPage = 0; +$NetflixJson = "["; + +while ($LastPage === FALSE) { + $ch = curl_init("https://www.netflix.com/api/shakti/7742b8c7/viewingactivity?pg=" . (string)$CurPage . "&pgSize=100"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_COOKIE, $NetflixCookie); + $Result = curl_exec($ch); + //echo $Result; + //echo count(json_decode(curl_exec($ch),true)["viewedItems"]); + if ($LastPage = count(json_decode($Result, TRUE)["viewedItems"][0]) > 0) { + $LastPage = FALSE; + $NetflixJson .= json_encode(json_decode($Result, TRUE)["viewedItems"][0]) . ","; + } else { + $LastPage = TRUE; + } + + curl_close($ch); + $CurPage++; +} + +print_r($NetflixJson . "]");
\ No newline at end of file |