Hacker News new | ask | show | jobs
by richardpetersen 4163 days ago
How do you get the script to save the json file?
2 comments

Or, you can write it from within Ruby:

    open("out.json", "w") {|f| f.puts JSON.dump(showings) }

    f << JSON.dump(showings)
avoids adding any new lines (not that it really matters in the case of JSON)
Doh, yes. `print` rather than `puts` is also acceptable.
You can redirect the output of the script to a json file, so in this case something like:

$ ruby scraper.rb > showings.json

Perfect, thank you