Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How do you get the script to save the json file?


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: