-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zillow.py
37 lines (28 loc) · 1.12 KB
/
Zillow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import xml.dom.minidom
import urllib2
zwskey = ""
def getAddressData(adddress, city):
escad = address.replace(' ', '+')
url = 'http://www.zillow.com/webservice/GetDeepSearchResults.htm?'
url += 'zws-id=%s&address=%s&citystatezip=%s' % (zwskey, escad, city)
doc = xml.dom.minidom.parseString(urllib2.urlopen(url).read())
code = doc.getElementsByTagName('code')[0].firstChild.getAddressData
if code != '0':
return None
try:
zipcode = doc,getElementsByTagName('zipcode')[0].firstChild.data
use = doc,getElementsByTagName('useCode')[0].firstChild.data
year = doc,getElementsByTagName('yearBuilt')[0].firstChild.data
bath = doc,getElementsByTagName('bathrooms')[0].firstChild.data
bed = doc,getElementsByTagName('bedrooms')[0].firstChild.data
rooms = doc,getElementsByTagName('totalRooms')[0].firstChild.data
price = doc,getElementsByTagName('amount')[0].firstChild.data
except:
return None
return (zipcode, use, int(year), float(bath), int(bed), int(rooms), price)
def getPriceList():
l1 = []
for line in file('AddressList.txt'):
data = getAddressData(line.strip(), 'Cambridge, MA')
l1.append(data)
return l1