node. js Crawler Bulk Download US drama from everyone movie Hr-hdtv

Source: Internet
Author: User
Tags sublime editor

These two days found a site called to see, is known to the Big Neusuli Ann, which crawler use of node. js. Here, for the last blog of the United States play small reptile, switch to Nodejs to achieve, experience a powerful node. js.
If you've never used JavaScript before, go to http://www.codecademy.com/to get started with JavaScript and JQuery and quickly get familiar with the basic syntax, and there's plenty of other languages to base your day. With a basic understanding, you will find two major features of JavaScript:
    • Using the prototype (prototype)-based approach for object-oriented programming;
    • Functional programming, interested in functional style recommended Racket (original PLT Scheme);

node. JS is a JavaScript runtime platform based on the Google V8 engine that makes it easy to write fast and extensible Web applications. node. JS takes an event-driven, non-blocking I/O model, which makes it lightweight and efficient and ideal for data-intensive real-time applications running on distributed devices. With node. js This runtime, JavaScript does not have to run in the browser, the application is greatly increased, such as the following small crawler, crawling is the "card house" high-definition Download link:

First install two libraries, in the current project directory with the following command line command://NPM Install request//npm Install Cheeriovar request = require ("request"); Request is used for requesting data var Cheerio = require ("Cheerio"); Cherrio is using jquery syntax to parse htmlvar URL = "http://www.yyets.com/resource/28793"; Request (URL, function (error, response, body) {    if (!error && response.statuscode = = =) {        var $ = Cheeri O.load (body);        $ (' [type= ' ed2k "]). each (function () {            var link = $ (this). attr (' href ');            if (typeof)! = ' undefined ' && link.indexof ("1024x768") >-1) {                console.log (link);});}    ); /Name the file Download.js (or whatever)//Open command-line window execution (PowerShell recommended under Windows)://         node download.js > link.txt//Pass Over-directed output, the download link is stored in link.txt this text file//tip: Hold down the "shift" key, the current folder in the white space right there will be open command line Options//tip: Recommended Sublime editor, install JS format and terminal plugin
"Address: http://blog.csdn.net/thisinnocence/article/details/40404219"

node. js Crawler Bulk Download US drama from everyone movie Hr-hdtv

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.