Replicate Netflix login and generate cookie

送分小仙女□ 提交于 2019-12-03 09:07:20

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 :

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);
}

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:

  • You can create native apps (i.e. Android, iOS, Windows Phone) and use the built in browser components that all mentioned platforms have.
  • Create a backend API that process one or more login and share the login with many users (if usage terms allows it). The users can be in a browser or native app.
  • Browser only for your private usage (or used by others using their own login).

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.

Ajaypayne

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 a session 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!