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