how to parse links by class name using node.js?

3EBC

New Member
This server gets all links of google's first site:\[code\]var http = require('http');var qs = require('querystring');var request = require("request");var cheerio = require('cheerio');http.createServer().listen(1337, "127.0.0.1");function parsehl(body, callback){ $ = cheerio.load(body); var result = ''; links = $('a'); //jquery get all hyperlinks ??????? $(links).each(function(i, link){ var hyperlink = '\n'+ $(link).attr('href'); result = result + hyperlink ; }); callback(result);} request({uri: 'http://www.google.com/search?q=rio&start=00' }, function (error, response, body) { console.log('url requested ') ; if (!error){ parsehl(body, function(result){ console.log(result); }); } else { console.log(error); } }); \[/code\]This server gets the links by tag name a.The links we need have the class name l (looks like nr 1 but is an l like in little).How can we get the links here by class name?We maybe need just one line where we put the questionmarks.
 
Back
Top