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 | |
parent | 0e0d074f5f3ef3bc0917e4dba9eb408f63014966 (diff) |
Added multiple page crawling
-rw-r--r-- | .idea/workspace.xml | 50 | ||||
-rw-r--r-- | assets/js/main.js | 15 | ||||
-rw-r--r-- | assets/php/getJson.php | 32 |
3 files changed, 54 insertions, 43 deletions
diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ee5e0f6..37d42c7 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,14 +2,8 @@ <project version="4"> <component name="ChangeListManager"> <list default="true" id="97b3211b-cf0c-4d16-95ab-95e8421b8759" name="Default" comment=""> - <change afterPath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/assets/css/main.css" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/assets/js/chart.js" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/assets/js/jQuery.js" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/assets/js/main.js" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/assets/php/getJson.php" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/index.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/assets/js/main.js" beforeDir="false" afterPath="$PROJECT_DIR$/assets/js/main.js" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/assets/php/getJson.php" beforeDir="false" afterPath="$PROJECT_DIR$/assets/php/getJson.php" afterDir="false" /> </list> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="TRACKING_ENABLED" value="true" /> @@ -32,8 +26,8 @@ <file leaf-file-name="main.js" pinned="false" current-in-tab="true"> <entry file="file://$PROJECT_DIR$/assets/js/main.js"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="897"> - <caret line="39" column="48" selection-start-line="39" selection-start-column="48" selection-end-line="39" selection-end-column="48" /> + <state relative-caret-position="506"> + <caret line="22" column="37" lean-forward="true" selection-start-line="22" selection-start-column="37" selection-end-line="22" selection-end-column="37" /> </state> </provider> </entry> @@ -41,8 +35,8 @@ <file leaf-file-name="getJson.php" pinned="false" current-in-tab="false"> <entry file="file://$PROJECT_DIR$/assets/php/getJson.php"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="207"> - <caret line="9" lean-forward="true" selection-start-line="9" selection-end-line="9" /> + <state relative-caret-position="440"> + <caret line="22" column="20" selection-start-line="22" selection-start-column="20" selection-end-line="22" selection-end-column="20" /> </state> </provider> </entry> @@ -63,8 +57,8 @@ <option value="$PROJECT_DIR$/assets/js/chart.js" /> <option value="$PROJECT_DIR$/assets/js/jQuery.js" /> <option value="$PROJECT_DIR$/index.html" /> - <option value="$PROJECT_DIR$/assets/php/getJson.php" /> <option value="$PROJECT_DIR$/assets/js/main.js" /> + <option value="$PROJECT_DIR$/assets/php/getJson.php" /> </list> </option> </component> @@ -79,8 +73,8 @@ </component> <component name="ProjectFrameBounds" extendedState="6"> <option name="x" value="1366" /> - <option name="width" value="624" /> - <option name="height" value="351" /> + <option name="width" value="2560" /> + <option name="height" value="1440" /> </component> <component name="ProjectLevelVcsManager"> <ConfirmationsSetting value="2" id="Add" /> @@ -204,12 +198,12 @@ <option name="presentableId" value="Default" /> <updated>1529337036914</updated> <workItem from="1529337040585" duration="712000" /> - <workItem from="1529337817654" duration="5574000" /> + <workItem from="1529337817654" duration="10788000" /> </task> <servers /> </component> <component name="TimeTrackingManager"> - <option name="totallyTimeSpent" value="6286000" /> + <option name="totallyTimeSpent" value="11500000" /> </component> <component name="ToolWindowManager"> <frame x="1366" y="0" width="2560" height="1440" extended-state="6" /> @@ -284,13 +278,6 @@ <entry file="file://$PROJECT_DIR$/assets/css/main.css"> <provider selected="true" editor-type-id="text-editor" /> </entry> - <entry file="file://$PROJECT_DIR$/index.html"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="253"> - <caret line="11" lean-forward="true" selection-start-line="11" selection-end-line="11" /> - </state> - </provider> - </entry> <entry file="file://$PROJECT_DIR$/assets/js/jQuery.js"> <provider selected="true" editor-type-id="text-editor"> <state relative-caret-position="30"> @@ -301,17 +288,24 @@ </state> </provider> </entry> + <entry file="file://$PROJECT_DIR$/index.html"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="253"> + <caret line="11" lean-forward="true" selection-start-line="11" selection-end-line="11" /> + </state> + </provider> + </entry> <entry file="file://$PROJECT_DIR$/assets/php/getJson.php"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="207"> - <caret line="9" lean-forward="true" selection-start-line="9" selection-end-line="9" /> + <state relative-caret-position="440"> + <caret line="22" column="20" selection-start-line="22" selection-start-column="20" selection-end-line="22" selection-end-column="20" /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/assets/js/main.js"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="897"> - <caret line="39" column="48" selection-start-line="39" selection-start-column="48" selection-end-line="39" selection-end-column="48" /> + <state relative-caret-position="506"> + <caret line="22" column="37" lean-forward="true" selection-start-line="22" selection-start-column="37" selection-end-line="22" selection-end-column="37" /> </state> </provider> </entry> diff --git a/assets/js/main.js b/assets/js/main.js index 1637da2..e7f5dcf 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -22,22 +22,23 @@ $(function () { * index: 0 * movieID: 80205354 * seasonDescriptor: "Teil 1" - * series: 80192098 + * series: 80192098 // => id * seriesTitle: "Haus des Geldes" * title: "Teil 1: \"Folge 13\"" - * topNodeId: "80192098" + * topNodeId: "80192098" // === id * videoTitle: "Folge 13" */ - NetflixJson = JSON.parse(answer); + document.write(answer); + /*NetflixJson = JSON.parse(answer); console.log(NetflixJson); let IndividualTitles = []; - NetflixJson.viewedItems.forEach(function(item, key) { - const CurrentTitle = NetflixJson.viewedItems[key].seriesTitle; - if (!(CurrentTitle in IndividualTitles)) { + NetflixJson.forEach(function(item, key) { + const CurrentTitle = NetflixJson[key].seriesTitle; + if (IndividualTitles.indexOf(CurrentTitle) === -1 && CurrentTitle !== undefined) { IndividualTitles.push(CurrentTitle); } }); - console.table(IndividualTitles); + console.log(IndividualTitles);*/ }); CookieInput.val(""); 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 |