views:

89

answers:

4

I am extracting content from a web page using JS/JQuery and want to write the data to a comma separated file. I know javascript doesn't really support file io and I'm trying to avoid setting up a local apache server just to process the content to a file. Is there an easier way to do this?

A: 

You can write a Mozilla Extension.

PROs:

You can use JS/JQuery on the extension You can write files on the extension

CONs:

You can only use the application in Firefox (or any other Mozilla based browser).

Pablo Santa Cruz
+4  A: 

You can have your JS create the file text in a string. Then open a new window and write the string into the new window.

Scott Saunders
Basically what I was going to suggest. Once you write it into a window the user can just do File > Save As to save the CSV to their computer. If you generate a data URI you could even specify content-type, ensuring that they get plaintext: http://en.wikipedia.org/wiki/Data_URI_scheme
Jordan
A: 

There is no simple way of doing this. W3C has recently published the first draft of a File API that will make it possible, but it'll be a while until this is through and widely implemented.

Thomas Kappler
A: 

Still requires a webserver, but you could build a small one method web service that your js calls, then the service can write out the data.

BioBuckyBall