Is it possible to use node.js as a faster, more elegant, database enabled alternative to greasemonkey?

StackOverflow https://stackoverflow.com/questions/11161633

Frage

I was using Greasemonkey eariler in the week to automate some calls to a page to scrape some data from a website, this was awkward for two reasons:

  1. It's GUI based instead of commandline based)
  2. I had to store all persisted information in JSON, and not directly in a database.

Would it be possible, to use node.js as a Greasemonkey alternative since node.js can store records directly in a database, and won't be required visually load pages the way the Greasemonkey does?

Also I would think that node.js would be easier to work with since you don't have to re-deploy it's scripts to Firefox the way that you have to with GreaseMonkey, allowing you to easily use version control on separate scripting projects.

On the other hand using node.js to do GreaseMonkey's job might just be using a hammer to pound in a screw, so I thought I would check here to find out if I am mistaken.

War es hilfreich?

Lösung

On the other hand using node.js to do GreaseMonkey's job might just be using a hammer to pound in a screw

I would say that the opposite is true; I believe you're using Greasemonkey to do the job of a server-side processing library. Greasemonkey runs in the browser and is designed to modify your web experience by running scripts on the pages you visit.

Indeed, I believe Node.js would be very well suited to this task. With libraries like jsdom and node-jquery, you can easily do JavaScript parsing over the DOM. You may also wish to take a look at node.io, a "distributed data scraping and processing framework." Finally, you may look into non-Node (but still JavaScript) based tools, such as PhantomJS and CasperJS, which can do scraping, DOM manipulation, screenshots, and more.

Andere Tipps

The question is a bit of a non sequitur.

Greasemonkey is for clients to tweak their individual browsing experience, client-side.

Node.js is for developers to deliver applications to the masses (hopefully), server-side.


For scraping data, in an automatable way, use Node.js or some server-side library (Python works well).

For "Mashups" of webpages that you browse, use Greasemonkey.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top