PageRenderTime 24ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/addNotableGroceryStores.rb

https://github.com/rantav/recipitor-frontend
Ruby | 7 lines | 1 code | 2 blank | 4 comment | 0 complexity | 2c14616d1e45075fed84cd8b781efff9 MD5 | raw file
  1. # To run this:
  2. # $ heroku console.
  3. # >> Paste this long line
  4. # condensed in one line for heroku's console; yuk
  5. g = JSON.parse(IO.read('NotableGroceryStores.json')); g['map'].each { |k,v|; puts k; r = Net::HTTP.get 'api.duckduckgo.com', "/?q=#{URI.escape(k)}&o=json"; j = JSON.parse(r); url = nil; url = j['Results'][0]['FirstURL'] if j and j['Results'] and j['Results'][0]; StoreChain.create(:name => k, :url => url) and puts url}