-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
39 lines (27 loc) · 1.42 KB
/
Copy pathREADME
File metadata and controls
39 lines (27 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
CrawlCL is a command line tool to crawl web pages using javascript and jquery. CrawlCL
uses node.js, including the modules request and jsdom. It's based on this article by
Charlie Robbins: http://blog.nodejitsu.com/jsdom-jquery-in-5-lines-on-nodejs .
To use crawlcl, you need to specify the page you want to crawl, the Sizzle.js/JQuery style
CSS selector, and optionally a javascript file that will be executed for each result
(The default action is to write out the href of each result).
Here's a simple example for parsing http://news.ycombinator.com/ and retrieving
some info about each of the results.
To execute this query:
./crawlcl http://news.ycombinator.com ".title a" sample.js
The sample.js contains the following:
if(node.href.substring(0,3) != "/x?"){ // remove the "More" link
console.log("Title: " + $(node).text());
console.log("HREF: " + node.href);
// Ugly but it works
var score = $(node).parent().parent().next().find('span');
console.log("Score: " + score.text());
console.log("Author: " + score.next().text());
}
To install crawlcl, you need to do the following:
1) Install node.js from http://nodejs.org/
2) Install the request and jsdom modules. The easiest way
to do this is to use NPM (http://npmjs.org/). If installed,
just type:
npm install request jsdom
3) At this point, you should be good to go. I've included the
sample.js file so you can try it with the above example query.