3

What is a good server-side javascript implementation for writing both one-off scripts to handle some task or writing automation scripts to be used over and over.

I am intrigued by the ability for SSJS to scrape webpages with such ease and am thinking SSJS could replace Python for my generic scripting needs. Is there a SSJS implementation for such things?

3 Answers 3

3

If you're familiar with jQuery, then node.js (with the plugins "request", "jsdom", and a port of jquery) let's you easily scrape web pages using jQuery in only a few lines.

The below will print a list of the all the questions on stack overflow's homepage to your console:

// Importing required modules
var request = require("request"),
    $ = require("jquery");

request({uri: "http://www.stackoverflow.com/"}, function (err, response, body) {
   $(body).find("#question-mini-list h3 a").each(function () {
      console.log($(this).text());
   });
});

Or if you use another javascript framework in the browser, it's not hard creating your own port of MooTools, Prototype or whatever using jsdom for node.js (it's just a matter of wrapping whatever library to provide it with window, document and other global variables - which jsdom gives you access to).

Sign up to request clarification or add additional context in comments.

Comments

1

I'm a fan of node.js. Although its main strength is in building servers (which is apparently not your intention) it is sufficiently versatile and definately worth a look.

Comments

0

I've had good results with Rhino + Quartz

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.