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

查看:41
本文介绍了复制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. 的 GET 请求
  3. 按照重定向结束/Login?locale=en-DE 之类的内容
  4. 提取 authURL 值(稍后登录 POST 需要)
  5. https://assets.nflxext 上的 GET 请求.com/us/ffe/siteui/logging/clientNotifications.min.20150626.js
  6. [失败] 根据该 JavaScript 的内容生成并设置cL"cookie
  7. https://www.netflix.com/Login?locale=en 的 POST 请求-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

我认为登录失败,因为我无法获取cL"cookie 的数据.对于每个请求,我使用与 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.

以下是一些附加说明:

  • 我不想使用浏览器登录 Netflix 网站.
  • 我想以编程方式登录 Netflix.(这就是我在 Stackoverflow 上问这个问题的原因).
  • 我不想编写 JavaScript 应用程序,而且我从未说过我想要,事实上我什至不知道我将使用哪种编程语言来实现它.
  • 我不想编写浏览器.
  • 我花了几个小时来记录/逆向工程登录请求.(我使用了 Fiddler 和 IE 的开发工具.)
  • 我不打算用它做任何违法的事情,这只是一个私人项目.

推荐答案

您要查找的内容称为 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天全站免登陆