Skip to content

Instantly share code, notes, and snippets.

@vlandham
Created November 7, 2013 18:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vlandham/7359931 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'json'
require 'open-uri'
BASE_URL = "http://shop.nordstrom.com/FashionSearch.axd"
SEARCH = "color=metallic"
output_filename = "metals.json"
still_searching = true
current_page = 1
page_search = ""
fashions = []
while still_searching
url = [BASE_URL, "?", SEARCH, "&", page_search].join("")
puts url
json = JSON.parse(open(url).read)
fashions = fashions.concat(json["Fashions"])
current_page += 1
page_search = "page=#{current_page}"
if current_page > 200
still_searching = false
end
end
File.open(output_filename, 'w') do |file|
file.puts JSON.pretty_generate(JSON.parse(fashions.to_json))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment