Skip to content

Instantly share code, notes, and snippets.

@olifante
Last active August 14, 2022 18:07
Show Gist options
  • Save olifante/6193a15215996485b9fa9e11131b60a8 to your computer and use it in GitHub Desktop.
Save olifante/6193a15215996485b9fa9e11131b60a8 to your computer and use it in GitHub Desktop.
// This short JavaScript fragment lets you export your Netflix list as a JSON
// file. Just navigate to the https://www.netflix.com/browse/my-list page,
// open your browser's Developer Tools, select the Console tab and paste this
// fragment. After it has run, you should be able to copy the output and save it
// into a file with the ".json" extension.
let movies = {};
document
.querySelectorAll(".slider-item .slider-refocus")
.forEach(function (el, key, parent) {
let title = el.getAttribute("aria-label");
// The URL should be similar to this:
// /watch/60023642?tctx=0%2C2%2C%2C%2C%2C%2C%2C%2C
let URL = el.getAttribute("href");
// Fetch the last element of the URL path and strip the query parameters
let ID = URL.split("/")[2].split("?")[0];
let movieURL = `https://www.netflix.com/title/${ID}`;
movies[ID] = { title, movieURL };
});
console.log(JSON.stringify(movies, null, 2));
// Sample output:
// {
// "60023642": {
// "title": "Spirited Away",
// "movieURL": "https://www.netflix.com/title/60023642"
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment