nrabinowitz / pjscrape

A web-scraping framework written in Javascript, using PhantomJS and jQuery
http://nrabinowitz.github.io/pjscrape/
MIT License
996 stars 159 forks source link

Saving JSON to external file #22

Closed crazy4groovy closed 12 years ago

crazy4groovy commented 12 years ago

How do I specify and export scraped data into a file instead printing to the screen? Would be nice to have in documentation. I am using PhantomJS 1.6. Thanks!

nrabinowitz commented 12 years ago

There are two easy ways to do this:

  1. Redirect STDOUT to a file:

    ~> phantomjs pjscrape.js my_script.js > my_output.json
  2. Use the "file" writer and set the outFile config parameter: see https://github.com/nrabinowitz/pjscrape/blob/master/tests/file_output_config.js

I'll try to add to the docs - haven't had much chance to update lately.

crazy4groovy commented 12 years ago

I knew about 1., but 2. is great. Thanks!