Since there is no official public Netflix API anymore, I'm trying to reverse engineer some things on my own. But I'm kind of stuck at the login.
What I'm doing:
- GET request on https://www.netflix.com/Login
- Follow the redirects to end up on something like /Login?locale=en-DE
- Extract the authURL value (required for the login POST later on)
- GET request on https://assets.nflxext.com/us/ffe/siteui/logging/clientNotifications.min.20150626.js
- [Failed] Generate and set the "cL" cookie from the content of that JavaScript
- POST request on https://www.netflix.com/Login?locale=en-DE using the following body format:
authURL=EXTRACTED_AUTH_URL&email=YOUR_EMAIL&password=YOUR_PASSWORD&RememberMe=on
I think the login fails, because I was not able to obtain the data for the "cL" cookie. For every request I used the exact same request headers as Internet Explorer did.
So I'm looking for a way to get the data from that JavaScript. Probably using regex? But that JavaScript is so minified and unreadable. :/ Some variables like appId and sessionId are still readable, but all the functions and other things have no names other than a,b,c. I tried to use the debugger to walk through that code, but this is just way to much for my brain.
Here are some additional notes:
- I don't want to login on the Netflix website using my browser.
- I want to login to Netflix programmatically. (That's why I asked this question on Stackoverflow).
- I do not want to write a JavaScript application and I never said I'd want to, in fact I don't even know which programming language I am going to use to implement this.
- I do not want to write a browser.
- I spent multiple hours on logging/reverse engineering the login requests. (I used Fiddler and IE's dev tools.)
- I am not planning to do anything illegal with this, it is just a private project.
What you're looking for is called Web Scraping / Web Crawling.
You can do it with the WebBrowser component from .NET as gregswiss pointed out, but you can also do it with :
Python : Scrapy (The most popular web scraper, Also you'll find lot of tutorials)
Javascript : Casper JS (wich relies on Phantom JS a headless web browser)
Java : Jaunt (it is my favorite, comes with relevant examples), or write your own web scraper using org.apache.commons.httpclient.
PHP : http://www.programminghelp.com/php/basic-web-scraping-regex-php/ http://www.jacobward.co.uk/web-scraping-with-php-curl-part-1/
Here is an example for logging in with jaunt :
You can find more example here : http://jaunt-api.com/jaunt-tutorial.htm
There exist a number of approaches that you can use to get Netflix working. You can make you own API which is not that hard. If you intend to have it for your own purposes that will be overkill, but if you intend to have at least some users it is feasible. The main thing you need to remember is that usually a first call is required (to save/get cookie). After that you can login and later display the content to the user or create you own design from the fetched data. Your relevant options:
I use a combination of the first and second option in a project of mine. However, my project is not related to anything close to yours except for that it use cookies, login and API. Good luck!
If you are using .NET, maybe a simpler approach would be to use a WebBrowser control.
Simply point it to http://www.netflix.com. You can then set username/password and simulate a click to the submit button and extract data from your pages using DOM. You won't have to worry about extracting and managing cookie etc. as it's essentially taken care of.
Inspect the requests in the network tab, replicate them using
postman
or something similar to see if they work from anywhere or if you need to have asession cookie
, then write a script in your chosen language to handle the posts that you will use.Without giving us more information, you can't really expect people to be able to help any more than this.