复制Netflix登录并生成cookie [英] Replicate Netflix login and generate cookie

查看:2476
本文介绍了复制Netflix登录并生成cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于没有正式的公共Netflix API了,我试图逆向工程我自己的一些东西。

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.

我在做什么:


  1. https://www.netflix.com/Login 上获取请求

  2. 按照重定向到达/ home?locale = en-DE

  3. 提取authURL值(稍后登录POST所需)

  4. https: //assets.nflxext.com/us/ffe/siteui/logging/clientNotifications.min.20150626.js

  5. [失败]生成并设置cLCookie该JavaScript的内容

  6. https: //www.netflix.com/Login?locale=en-DE 使用以下正文格式: authURL = EXTRACTED_AUTH_URL& email = YOUR_EMAIL& password = YOUR_PASSWORD& RememberMe = on

  1. GET request on https://www.netflix.com/Login
  2. Follow the redirects to end up on something like /Login?locale=en-DE
  3. Extract the authURL value (required for the login POST later on)
  4. GET request on https://assets.nflxext.com/us/ffe/siteui/logging/clientNotifications.min.20150626.js
  5. [Failed] Generate and set the "cL" cookie from the content of that JavaScript
  6. 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

我认为登录失败,因为我无法获取cLcookie的数据。对于每个请求,我使用了与Internet Explorer完全相同的请求头。

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.

所以我正在寻找一种方法来获取JavaScript的数据。可能使用正则表达式?但是JavaScript是如此缩小和不可读。 :/像appId和sessionId这样的变量仍然可读,但是所有的函数和其他东西都没有除a,b,c之外的名字。我试图使用调试器来遍历该代码,但这只是对我的大脑的方式。

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:


  • 我不想登入在Netflix网站上使用我的浏览器。

  • 我想以编程方式登入Netflix。 (这就是为什么我问这个问题在Stackoverflow)。

  • 我不想写一个JavaScript应用程序,我从来没有说过我想要的,实际上我甚至不知道我将使用哪种编程语言来实现这一点。

  • 我不想编写浏览器。

  • 我在记录/反向工程的登录请求上花了多个小时。 (我使用Fiddler和IE的开发工具。)

  • 我不打算做任何违法的事情,这只是一个私人项目。

  • 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.

推荐答案

您正在寻找的是Web Scraping / Web Crawling。

What you're looking for is called Web Scraping / Web Crawling.

您可以像gregswiss指出的那样使用.NET的WebBrowser组件,但您也可以使用:

You can do it with the WebBrowser component from .NET as gregswiss pointed out, but you can also do it with :

Python :Scrapy (最流行的网络刮板,也可以找到很多教程)

Python : Scrapy (The most popular web scraper, Also you'll find lot of tutorials)

Javascript :Casper JS(依赖Phantom JS无头网络浏览器)

Javascript : Casper JS (wich relies on Phantom JS a headless web browser)

Java :Jaunt(它是我最喜欢的,附带相关示例),或者使用org.apache .commons.httpclient。

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 /

以下是使用jaunt登录的示例:

Here is an example for logging in with jaunt :

try{
  UserAgent userAgent = new UserAgent(); 
  userAgent.visit("http://jaunt-api.com/examples/login.htm");

  userAgent.doc.fillout("Username:", "tom");       //fill out the component labelled 'Username:' with "tom"
  userAgent.doc.fillout("Password:", "secret");    //fill out the component labelled 'Password:' with "secret"
  userAgent.doc.choose(Label.RIGHT, "Remember me");//choose the component right-labelled 'Remember me'.
  userAgent.doc.submit();                          //submit the form
  System.out.println(userAgent.getLocation());     //print the current location (url)
}
catch(JauntException e){
  System.err.println(e);
}

您可以在这里找到更多示例: http://jaunt-api.com/jaunt-tutorial.htm

You can find more example here : http://jaunt-api.com/jaunt-tutorial.htm

这篇关于复制Netflix登录并生成cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆