Re:Web scraping with Ruby
by richardpetersen on Monday January 19, 2015 @06:54AM
(#8911488)
How do you get the script to save the json file?
[ Parent
| on HN ]
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.
Re:Web scraping with Ruby
by hecticjeff on Monday January 19, 2015 @06:58AM
(#8911496)
You can redirect the output of the script to a json file, so in this case something like:
$ ruby scraper.rb > showings.json
Re:Web scraping with Ruby
by richardpetersen on Monday January 19, 2015 @07:11AM
(#8911535)
Perfect, thank you