zillow_api 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/zillow_api.rb +53 -35
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 983064ad60143a3331d18d29b430e514bbb4ed63
|
4
|
+
data.tar.gz: e99b2335b22f55c229dc8d9cc401c3f3319a223f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eb5b499a26d3719a5e52c78d7ba1f04a6ff61f704c809541b0c84a33d6037c85541d58701a4bf6c6c697e854a32eebffbc2028c172b81b7a977a394b16d6406
|
7
|
+
data.tar.gz: c33aa0d8beb0a3fdb9298cd2670411649f09a977329347aa8ba22613d152180ccba796dfd75af95bf0ee460c59014fb81a9bbdba7d23c94c74666633cf648f24
|
data/lib/zillow_api.rb
CHANGED
@@ -30,8 +30,10 @@ class ZillowAPI
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def get_property_by_address(address_num
|
34
|
-
if
|
33
|
+
def get_property_by_address(address_num:nil, address_street:, address_street_type:nil,address_city:nil,address_state:nil,address_zip:nil)
|
34
|
+
if address_num.nil? && (address_street && address_zip)
|
35
|
+
property = Nokogiri::HTML(open("#{ZILLOW_API_URL}&zws-id=#{@api_key}&address=#{CGI::escape(address_street)}&citystatezip=#{CGI::escape(address_zip)}"))
|
36
|
+
elsif address_zip && address_street_type
|
35
37
|
property = Nokogiri::HTML(open("#{ZILLOW_API_URL}&zws-id=#{@api_key}&address=#{CGI::escape(address_num)}%20#{CGI::escape(address_street)}%20#{CGI::escape(address_street_type)}&citystatezip=#{CGI::escape(address_zip)}"))
|
36
38
|
elsif address_zip && address_street_type.nil?
|
37
39
|
property = Nokogiri::HTML(open("#{ZILLOW_API_URL}&zws-id=#{@api_key}&address=#{CGI::escape(address_num)}%20#{CGI::escape(address_street)}&citystatezip=#{CGI::escape(address_zip)}"))
|
@@ -46,17 +48,17 @@ class ZillowAPI
|
|
46
48
|
if property.css("zpid")[0].text.to_i.to_s == property.css("zpid")[0].text
|
47
49
|
property_data = {}
|
48
50
|
property_data = { zpid: property.css("zpid")[0].text,
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
street: property.css("address")[1].children[0].text,
|
52
|
+
zip_code: property.css("address")[1].children[1].text,
|
53
|
+
city: property.css("address")[1].children[2].text.downcase,
|
54
|
+
state: property.css("address")[1].children[3].text.downcase,
|
55
|
+
latitude: property.css("address")[1].children[4].text,
|
56
|
+
longitude: property.css("address")[1].children[5].text,
|
57
|
+
zestimate: property.css("zestimate")[0].children[0].text,
|
58
|
+
rent_zestimate: property.css("rentzestimate")[0].children[0].text,
|
59
|
+
neighborhood_id: property.css("localrealestate")[0].children.css("region").first["id"],
|
60
|
+
neighborhood_name: property.css("localrealestate")[0].children.css("region").first["name"],
|
61
|
+
neighborhood_type: property.css("localrealestate")[0].children.css("region").first["type"]
|
60
62
|
}
|
61
63
|
return property_data
|
62
64
|
else
|
@@ -70,14 +72,14 @@ class ZillowAPI
|
|
70
72
|
if property.css("zpid")[0].text.to_i.to_s == property.css("zpid")[0].text
|
71
73
|
property_data = {}
|
72
74
|
property_data = { zpid: property.css("zpid")[0].text,
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
street: property.css("address").children[0].text,
|
76
|
+
zip_code: property.css("address").children[1].text,
|
77
|
+
city: property.css("address").children[2].text.downcase,
|
78
|
+
state: property.css("address").children[3].text.downcase,
|
79
|
+
latitude: property.css("address").children[4].text,
|
80
|
+
longitude: property.css("address").children[5].text,
|
81
|
+
zestimate: property.css("amount").children[0].text,
|
82
|
+
rent_zestimate: property.css("rentzestimate")[0].children[0].text
|
81
83
|
}
|
82
84
|
return property_data
|
83
85
|
else
|
@@ -85,24 +87,40 @@ class ZillowAPI
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
88
|
-
|
89
|
-
def get_demographics_by_id(regionid:)
|
90
|
+
def get_demographics_by_id(regionid)
|
90
91
|
demo_stats = Nokogiri::HTML(open("#{ZILLOW_DEMO_URL}&zws-id=#{@api_key}®ionid=#{CGI::escape(regionid)}"))
|
91
92
|
if demo_stats.css("regionid").text.to_i.to_s == demo_stats.css("regionid").text
|
92
93
|
demo_data = {}
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
94
|
+
neighborhood_data = {}
|
95
|
+
nation_data = {}
|
96
|
+
city_data = {}
|
97
|
+
|
98
|
+
#get city data
|
99
|
+
demo_stats.css("attribute").each do |att|
|
100
|
+
city_data[att.css("name").text.downcase] = att.css("city").text.downcase
|
101
|
+
end
|
102
|
+
|
103
|
+
#get neighborhood data
|
104
|
+
demo_stats.css("attribute").each do |att|
|
105
|
+
neighborhood_data[att.css("name").text.downcase] = att.css("neighborhood").text.downcase
|
106
|
+
end
|
107
|
+
|
108
|
+
#get nation data
|
109
|
+
demo_stats.css("attribute").each do |att|
|
110
|
+
nation_data[att.css("name").text.downcase] = att.css("nation").text.downcase
|
111
|
+
end
|
112
|
+
|
113
|
+
demo_data = { id: demo_stats.css("region").children[0].text,
|
114
|
+
state: demo_stats.css("region").children[1].text.downcase,
|
115
|
+
city: demo_stats.css("region").children[2].text.downcase,
|
116
|
+
neighborhood: demo_stats.css("region").children[3].text.downcase,
|
117
|
+
latitude: demo_stats.css("region").children[4].text,
|
118
|
+
longitude: demo_stats.css("region").children[5].text,
|
119
|
+
neighborhood_data: neighborhood_data,
|
120
|
+
city_data: city_data,
|
121
|
+
nation_data: nation_data
|
104
122
|
}
|
105
|
-
return
|
123
|
+
return demo_data
|
106
124
|
else
|
107
125
|
return {zillow_error_code: demo_stats.css('message').children[1].text, zillow_error_code_text: demo_stats.css('message').children[0].text}
|
108
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zillow_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Freeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Gem for interfacing with Zillow API
|
14
14
|
email: benfreeman@gmail.com
|