我在http://www.zillow.com/webservice/GetSearchResults.htm 访问Zillow 的 seach API,并使用 HTTParty 将代码转换为 JSON。我将如何提取特定值,例如“地址”或“城市”?
我正在尝试类似的东西response.price
,但那是错误的。然后我在尝试response[0]
和response['city']
,诸如此类的事情......
[1] pry(Zillow)> response
=> {"searchresults"=>
{"request"=>{"address"=>"7 Clive St UNIT 2", "citystatezip"=>"02130"},
"message"=>{"text"=>"Request successfully processed", "code"=>"0"},
"response"=>
{"results"=>
{"result"=>
{"zpid"=>"120921393",
"links"=>
{"homedetails"=>
"http://www.zillow.com/homedetails/7-Clive-St-UNIT-2-Jamaica-Plain-M
"graphsanddata"=>
"http://www.zillow.com/homedetails/7-Clive-St-UNIT-2-Jamaica-Plain-M
"mapthishome"=>"http://www.zillow.com/homes/120921393_zpid/",
"comparables"=>"http://www.zillow.com/homes/comps/120921393_zpid/"},
"address"=>
{"street"=>"7 Clive St UNIT 2",
"zipcode"=>"02130",
"city"=>"Jamaica Plain",
"state"=>"MA",
"latitude"=>"42.317562",
"longitude"=>"-71.108245"},
"zestimate"=>
{"amount"=>{"__content__"=>"500537", "currency"=>"USD"},
"last_updated"=>"04/20/2014",
"oneWeekChange"=>{"deprecated"=>"true"},
"valueChange"=>nil,
"valuationRange"=>
{"low"=>{"__content__"=>"475510", "currency"=>"USD"},
"high"=>{"__content__"=>"525564", "currency"=>"USD"}},
"percentile"=>"0"},
"localRealEstate"=>
{"region"=>
{"links"=>
{"overview"=>
"http://www.zillow.com/local-info/MA-Boston/Jamaica-Plain/r_1547
"forSaleByOwner"=>
"http://www.zillow.com/jamaica-plain-boston-ma/fsbo/",
"forSale"=>"http://www.zillow.com/jamaica-plain-boston-ma/"},
"id"=>"154795",
"type"=>"neighborhood",
"name"=>"Jamaica Plain"}}}}},
"schemaLocation"=>
"http://www.zillow.com/static/xsd/SearchResults.xsd http://www.zillowstatic.
(END)