def seed_towns(): print "Seeding Towns tables..." towns_file = 'current/data/uk-towns-list/uk-towns.csv' print towns_file Town.drop_table(fail_silently=True) Town.create_table(fail_silently=True) rq = RawQuery(Town, "COPY uk_towns FROM '{0}' DELIMITERS ',' CSV HEADER".format(towns_file)) try: rq.execute() except TypeError, e: # Wierdness here assert Town.select().count() == 43143
def seed_towns(): print "Seeding Towns tables..." towns_file = 'current/data/uk-towns-list/uk-towns.csv' print towns_file Town.drop_table(fail_silently=True) Town.create_table(fail_silently=True) rq = RawQuery( Town, "COPY uk_towns FROM '{0}' DELIMITERS ',' CSV HEADER".format( towns_file)) try: rq.execute() except TypeError, e: # Wierdness here assert Town.select().count() == 43143
import datetime # Start the comments. # We need to save these objects before referencing them later. henry_hiker = Hiker( 'Henry', 'Hiker', "hhiker1", 'France', '*****@*****.**', 10, "https://res.cloudinary.com/c7oud0311/image/upload/v1594609854/project3/profile1_tbjthv.jpg" ).save() joe_jogger = Hiker( 'Joe', 'Jogger', "jjogger1", 'UK', '*****@*****.**', 12, "https://res.cloudinary.com/c7oud0311/image/upload/v1594654152/project3/profile2_vcog5c.jpg" ).save() location_ids = Location.objects.bulk_create([ Location('Ireland', province=[Province(state='Leinster', town=Town(town='Carlow'))]), Location('Ireland', province=[Province(state='Leinster', town=Town(town='Dublin'))]), Location('Ireland', province=[Province(state='Leinster', town=Town(town='Kilkenny'))]), Location('Ireland', province=[Province(state='Leinster', town=Town(town='Wicklow'))]), Location('Ireland', province=[Province(state='Munster', town=Town(town='Cork'))]), Location('Ireland', province=[Province(state='Munster', town=Town(town='Killarney'))]), # 5 Location('Ireland', province=[Province(state='Munster', town=Town(town='Limerick'))]), Location('Ireland',
def __init__(self, *args, **kwargs): super(SearchForm, self).__init__(*args, **kwargs) self.fields['type'].choices = Type.choices() self.fields['town'].choices = Town.choices()
from lxml import etree from models import Town sample = '<?xml version="1.0" encoding="utf-8"?><RegionChildren:regionchildren xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zillow.com/static/xsd/RegionChildren.xsd http://www.zillowstatic.com/vstatic/9549d1594cdd8acb6ed1ee6b69937273/static/xsd/RegionChildren.xsd" xmlns:RegionChildren="http://www.zillow.com/static/xsd/RegionChildren.xsd"><request><state>ny</state><county>suffolk</county></request><message><text>Request successfully processed</text><code>0</code></message><response><region><id>2046</id><latitude>40.884668</latitude><longitude>-72.676567</longitude></region><subregiontype>city</subregiontype><list><count>133</count><region><id>51128</id><name>Brentwood</name><zindex currency="USD">206700</zindex><url>http://www.zillow.com/local-info/NY-Brentwood/r_51128/</url><latitude>40.780978</latitude><longitude>-73.25253</longitude></region><region><id>43490</id><name>Lindenhurst</name><zindex currency="USD">278100</zindex><url>http://www.zillow.com/local-info/NY-Lindenhurst/r_43490/</url><latitude>40.690393</latitude><longitude>-73.375154</longitude></region><region><id>13218</id><name>Patchogue</name><zindex currency="USD">240900</zindex><url>http://www.zillow.com/local-info/NY-Patchogue/r_13218/</url><latitude>40.734872</latitude><longitude>-72.998932</longitude></region><region><id>41621</id><name>West Babylon</name><zindex currency="USD">285900</zindex><url>http://www.zillow.com/local-info/NY-West-Babylon/r_41621/</url><latitude>40.706639</latitude><longitude>-73.356009</longitude></region><region><id>13579</id><name>Ronkonkoma</name><zindex currency="USD">286200</zindex><url>http://www.zillow.com/local-info/NY-Ronkonkoma/r_13579/</url><latitude>40.81562</latitude><longitude>-73.115697</longitude></region><region><id>10768</id><name>Central Islip</name><zindex currency="USD">201200</zindex><url>http://www.zillow.com/local-info/NY-Central-Islip/r_10768/</url><latitude>40.779935</latitude><longitude>-73.198153</longitude></region><region><id>25219</id><name>Huntington Station</name><zindex currency="USD">290000</zindex><url>http://www.zillow.com/local-info/NY-Huntington-Station/r_25219/</url><latitude>40.847421</latitude><longitude>-73.401277</longitude></region><region><id>4484</id><name>East Northport</name><zindex currency="USD">400500</zindex><url>http://www.zillow.com/local-info/NY-East-Northport/r_4484/</url><latitude>40.859067</latitude><longitude>-73.315489</longitude></region><region><id>10762</id><name>Centereach</name><zindex currency="USD">270900</zindex><url>http://www.zillow.com/local-info/NY-Centereach/r_10762/</url><latitude>40.872937</latitude><longitude>-73.082649</longitude></region><region><id>44707</id><name>Commack</name><zindex currency="USD">399100</zindex><url>http://www.zillow.com/local-info/NY-Commack/r_44707/</url><latitude>40.839917</latitude><longitude>-73.279656</longitude></region><region><id>57124</id><name>Coram</name><zindex currency="USD">248200</zindex><url>http://www.zillow.com/local-info/NY-Coram/r_57124/</url><latitude>40.877839</latitude><longitude>-73.005458</longitude></region><region><id>23477</id><name>Amityville</name><zindex currency="USD">252700</zindex><url>http://www.zillow.com/local-info/NY-Amityville/r_23477/</url><latitude>40.686239</latitude><longitude>-73.410759</longitude></region><region><id>51677</id><name>Deer Park</name><zindex currency="USD">285200</zindex><url>http://www.zillow.com/local-info/NY-Deer-Park/r_51677/</url><latitude>40.763232</latitude><longitude>-73.322375</longitude></region><region><id>29786</id><name>Riverhead</name><zindex currency="USD">273500</zindex><url>http://www.zillow.com/local-info/NY-Riverhead/r_29786/</url><latitude>40.92404</latitude><longitude>-72.651003</longitude></region><region><id>21885</id><name>Holbrook</name><zindex currency="USD">320700</zindex><url>http://www.zillow.com/local-info/NY-Holbrook/r_21885/</url><latitude>40.799349</latitude><longitude>-73.067916</longitude></region><region><id>36041</id><name>Medford</name><zindex currency="USD">227800</zindex><url>http://www.zillow.com/local-info/NY-Medford/r_36041/</url><latitude>40.831609</latitude><longitude>-72.979514</longitude></region><region><id>17783</id><name>Dix Hills</name><zindex currency="USD">636300</zindex><url>http://www.zillow.com/local-info/NY-Dix-Hills/r_17783/</url><latitude>40.802606</latitude><longitude>-73.337197</longitude></region><region><id>56840</id><name>West Islip</name><zindex currency="USD">363700</zindex><url>http://www.zillow.com/local-info/NY-West-Islip/r_56840/</url><latitude>40.712891</latitude><longitude>-73.296078</longitude></region><region><id>7009</id><name>Selden</name><zindex currency="USD">234700</zindex><url>http://www.zillow.com/local-info/NY-Selden/r_7009/</url><latitude>40.871191</latitude><longitude>-73.036415</longitude></region><region><id>30360</id><name>Bay Shore</name><zindex currency="USD">259000</zindex><url>http://www.zillow.com/local-info/NY-Bay-Shore/r_30360/</url><latitude>40.72713</latitude><longitude>-73.254355</longitude></region><region><id>54443</id><name>Smithtown</name><zindex currency="USD">418800</zindex><url>http://www.zillow.com/local-info/NY-Smithtown/r_54443/</url><latitude>40.861984</latitude><longitude>-73.214031</longitude></region><region><id>33495</id><name>Port Jefferson Station</name><zindex currency="USD">277900</zindex><url>http://www.zillow.com/local-info/NY-Port-Jefferson-Station/r_33495/</url><latitude>40.913304</latitude><longitude>-73.042561</longitude></region><region><id>27287</id><name>Stony Brook</name><zindex currency="USD">375300</zindex><url>http://www.zillow.com/local-info/NY-Stony-Brook/r_27287/</url><latitude>40.908516</latitude><longitude>-73.125006</longitude></region><region><id>16112</id><name>Shirley</name><zindex currency="USD">194900</zindex><url>http://www.zillow.com/local-info/NY-Shirley/r_16112/</url><latitude>40.795728</latitude><longitude>-72.874459</longitude></region><region><id>24213</id><name>Copiague</name><zindex currency="USD">244600</zindex><url>http://www.zillow.com/local-info/NY-Copiague/r_24213/</url><latitude>40.678829</latitude><longitude>-73.394153</longitude></region><region><id>39253</id><name>Kings Park</name><zindex currency="USD">381000</zindex><url>http://www.zillow.com/local-info/NY-Kings-Park/r_39253/</url><latitude>40.887563</latitude><longitude>-73.250151</longitude></region><region><id>45244</id><name>Farmingville</name><zindex currency="USD">287000</zindex><url>http://www.zillow.com/local-info/NY-Farmingville/r_45244/</url><latitude>40.839791</latitude><longitude>-73.039928</longitude></region><region><id>25848</id><name>Melville</name><zindex currency="USD">526000</zindex><url>http://www.zillow.com/local-info/NY-Melville/r_25848/</url><latitude>40.783404</latitude><longitude>-73.408413</longitude></region><region><id>38922</id><name>Hauppauge</name><zindex currency="USD">406200</zindex><url>http://www.zillow.com/local-info/NY-Hauppauge/r_38922/</url><latitude>40.819548</latitude><longitude>-73.210046</longitude></region><region><id>42798</id><name>North Bay Shore</name><zindex currency="USD">226700</zindex><url>http://www.zillow.com/local-info/NY-North-Bay-Shore/r_42798/</url><latitude>40.700608</latitude><longitude>-73.2167</longitude></region><region><id>9043</id><name>North Babylon</name><zindex currency="USD">294800</zindex><url>http://www.zillow.com/local-info/NY-North-Babylon/r_9043/</url><latitude>40.732407</latitude><longitude>-73.325741</longitude></region><region><id>32120</id><name>Huntington</name><zindex currency="USD">502500</zindex><url>http://www.zillow.com/local-info/NY-Huntington/r_32120/</url><latitude>40.882176</latitude><longitude>-73.410528</longitude></region><region><id>21397</id><name>Wyandanch</name><zindex currency="USD">206600</zindex><url>http://www.zillow.com/local-info/NY-Wyandanch/r_21397/</url><latitude>40.752362</latitude><longitude>-73.372995</longitude></region><region><id>54331</id><name>Sayville</name><zindex currency="USD">371300</zindex><url>http://www.zillow.com/local-info/NY-Sayville/r_54331/</url><latitude>40.717465</latitude><longitude>-73.014358</longitude></region><region><id>32735</id><name>Mastic</name><zindex currency="USD">174500</zindex><url>http://www.zillow.com/local-info/NY-Mastic/r_32735/</url><latitude>40.809819</latitude><longitude>-72.846316</longitude></region><region><id>32172</id><name>Islip</name><zindex currency="USD">313000</zindex><url>http://www.zillow.com/local-info/NY-Islip/r_32172/</url><latitude>40.729311</latitude><longitude>-73.216258</longitude></region><region><id>396690</id><name>Setauket-East Setauket</name><zindex currency="USD">428600</zindex><url>http://www.zillow.com/local-info/NY-Setauket--East-Setauket/r_396690/</url><latitude>40.928766</latitude><longitude>-73.09889</longitude></region><region><id>46438</id><name>Mastic Beach</name><zindex currency="USD">156900</zindex><url>http://www.zillow.com/local-info/NY-Mastic-Beach/r_46438/</url><latitude>40.759026</latitude><longitude>-72.828975</longitude></region><region><id>19562</id><name>Nesconset</name><zindex currency="USD">385100</zindex><url>http://www.zillow.com/local-info/NY-Nesconset/r_19562/</url><latitude>40.844722</latitude><longitude>-73.145592</longitude></region><region><id>15797</id><name>Middle Island</name><zindex currency="USD">225400</zindex><url>http://www.zillow.com/local-info/NY-Middle-Island/r_15797/</url><latitude>40.882516</latitude><longitude>-72.952226</longitude></region><region><id>11957</id><name>Holtsville</name><zindex currency="USD">297900</zindex><url>http://www.zillow.com/local-info/NY-Holtsville/r_11957/</url><latitude>40.810777</latitude><longitude>-73.045774</longitude></region><region><id>17876</id><name>East Islip</name><zindex currency="USD">357000</zindex><url>http://www.zillow.com/local-info/NY-East-Islip/r_17876/</url><latitude>40.722856</latitude><longitude>-73.184019</longitude></region><region><id>8914</id><name>Manorville</name><zindex currency="USD">346900</zindex><url>http://www.zillow.com/local-info/NY-Manorville/r_8914/</url><latitude>40.862684</latitude><longitude>-72.799598</longitude></region><region><id>18451</id><name>Hampton Bays</name><zindex currency="USD">378300</zindex><url>http://www.zillow.com/local-info/NY-Hampton-Bays/r_18451/</url><latitude>40.87099</latitude><longitude>-72.524779</longitude></region><region><id>13567</id><name>Rocky Point</name><zindex currency="USD">244700</zindex><url>http://www.zillow.com/local-info/NY-Rocky-Point/r_13567/</url><latitude>40.936323</latitude><longitude>-72.935254</longitude></region><region><id>47513</id><name>Saint James</name><zindex currency="USD">366900</zindex><url>http://www.zillow.com/local-info/NY-Saint-James/r_47513/</url><latitude>40.881849</latitude><longitude>-73.153967</longitude></region><region><id>37238</id><name>Babylon</name><zindex currency="USD">369300</zindex><url>http://www.zillow.com/local-info/NY-Babylon/r_37238/</url><latitude>40.692684</latitude><longitude>-73.327994</longitude></region><region><id>39902</id><name>Mount Sinai</name><zindex currency="USD">349400</zindex><url>http://www.zillow.com/local-info/NY-Mount-Sinai/r_39902/</url><latitude>40.932536</latitude><longitude>-73.009138</longitude></region><region><id>5493</id><name>Lake Grove</name><zindex currency="USD">339200</zindex><url>http://www.zillow.com/local-info/NY-Lake-Grove/r_5493/</url><latitude>40.859176</latitude><longitude>-73.118832</longitude></region><region><id>13937</id><name>Southampton</name><zindex currency="USD">845200</zindex><url>http://www.zillow.com/local-info/NY-Southampton/r_13937/</url><latitude>40.907494</latitude><longitude>-72.403377</longitude></region><region><id>23258</id><name>Ridge</name><zindex currency="USD">193000</zindex><url>http://www.zillow.com/local-info/NY-Ridge/r_23258/</url><latitude>40.900671</latitude><longitude>-72.88417</longitude></region><region><id>5960</id><name>Miller Place</name><zindex currency="USD">345500</zindex><url>http://www.zillow.com/local-info/NY-Miller-Place/r_5960/</url><latitude>40.93827</latitude><longitude>-72.990087</longitude></region><region><id>3736</id><name>Bohemia</name><zindex currency="USD">345600</zindex><url>http://www.zillow.com/local-info/NY-Bohemia/r_3736/</url><latitude>40.770097</latitude><longitude>-73.126849</longitude></region><region><id>4982</id><name>Greenlawn</name><zindex currency="USD">440100</zindex><url>http://www.zillow.com/local-info/NY-Greenlawn/r_4982/</url><latitude>40.868211</latitude><longitude>-73.363907</longitude></region><region><id>39124</id><name>Islip Terrace</name><zindex currency="USD">305500</zindex><url>http://www.zillow.com/local-info/NY-Islip-Terrace/r_39124/</url><latitude>40.76131</latitude><longitude>-73.174212</longitude></region><region><id>7154</id><name>South Huntington</name><zindex currency="USD">355000</zindex><url>http://www.zillow.com/local-info/NY-South-Huntington/r_7154/</url><latitude>40.81532</latitude><longitude>-73.362825</longitude></region><region><id>24766</id><name>Fort Salonga</name><zindex currency="USD">618800</zindex><url>http://www.zillow.com/local-info/NY-Fort-Salonga/r_24766/</url><latitude>40.908334</latitude><longitude>-73.29178</longitude></region><region><id>26249</id><name>Oakdale</name><zindex currency="USD">382600</zindex><url>http://www.zillow.com/local-info/NY-Oakdale/r_26249/</url><latitude>40.735168</latitude><longitude>-73.129591</longitude></region><region><id>23662</id><name>Bellport</name><zindex currency="USD">231300</zindex><url>http://www.zillow.com/local-info/NY-Bellport/r_23662/</url><latitude>40.748688</latitude><longitude>-72.941617</longitude></region><region><id>48885</id><name>Bayport</name><zindex currency="USD">383200</zindex><url>http://www.zillow.com/local-info/NY-Bayport/r_48885/</url><latitude>40.74815</latitude><longitude>-73.055874</longitude></region><region><id>36642</id><name>Sound Beach</name><zindex currency="USD">244500</zindex><url>http://www.zillow.com/local-info/NY-Sound-Beach/r_36642/</url><latitude>40.955938</latitude><longitude>-72.970796</longitude></region><region><id>30703</id><name>Calverton</name><zindex currency="USD">294100</zindex><url>http://www.zillow.com/local-info/NY-Calverton/r_30703/</url><latitude>40.919003</latitude><longitude>-72.764015</longitude></region><region><id>33494</id><name>Port Jefferson</name><zindex currency="USD">396300</zindex><url>http://www.zillow.com/local-info/NY-Port-Jefferson/r_33494/</url><latitude>40.949794</latitude><longitude>-73.061018</longitude></region><region><id>43141</id><name>Wading River</name><zindex currency="USD">350200</zindex><url>http://www.zillow.com/local-info/NY-Wading-River/r_43141/</url><latitude>40.940627</latitude><longitude>-72.834997</longitude></region><region><id>50181</id><name>Northport</name><zindex currency="USD">458700</zindex><url>http://www.zillow.com/local-info/NY-Northport/r_50181/</url><latitude>40.913995</latitude><longitude>-73.320766</longitude></region><region><id>193195</id><name>Bay Wood</name><zindex currency="USD">239500</zindex><url>http://www.zillow.com/local-info/NY-Bay-Wood/r_193195/</url><latitude>40.755195</latitude><longitude>-73.2929</longitude></region><region><id>10760</id><name>Center Moriches</name><zindex currency="USD">305700</zindex><url>http://www.zillow.com/local-info/NY-Center-Moriches/r_10760/</url><latitude>40.792636</latitude><longitude>-72.794615</longitude></region><region><id>47685</id><name>Shoreham</name><zindex currency="USD">360000</zindex><url>http://www.zillow.com/local-info/NY-Shoreham/r_47685/</url><latitude>40.943817</latitude><longitude>-72.888241</longitude></region><region><id>13940</id><name>Southold</name><zindex currency="USD">497000</zindex><url>http://www.zillow.com/local-info/NY-Southold/r_13940/</url><latitude>41.063577</latitude><longitude>-72.426246</longitude></region><region><id>4028</id><name>Centerport</name><zindex currency="USD">461600</zindex><url>http://www.zillow.com/local-info/NY-Centerport/r_4028/</url><latitude>40.89446</latitude><longitude>-73.3714</longitude></region><region><id>198154</id><name>Springs</name><zindex currency="USD">557900</zindex><url>http://www.zillow.com/local-info/NY-Springs/r_198154/</url><latitude>41.022157</latitude><longitude>-72.155026</longitude></region><region><id>34745</id><name>West Hills</name><zindex currency="USD">514800</zindex><url>http://www.zillow.com/local-info/NY-West-Hills/r_34745/</url><latitude>40.821041</latitude><longitude>-73.431786</longitude></region><region><id>24506</id><name>East Quogue</name><zindex currency="USD">527600</zindex><url>http://www.zillow.com/local-info/NY-East-Quogue/r_24506/</url><latitude>40.854212</latitude><longitude>-72.581445</longitude></region><region><id>55276</id><name>Yaphank</name><zindex currency="USD">226600</zindex><url>http://www.zillow.com/local-info/NY-Yaphank/r_55276/</url><latitude>40.832807</latitude><longitude>-72.92135</longitude></region><region><id>4482</id><name>East Moriches</name><zindex currency="USD">325900</zindex><url>http://www.zillow.com/local-info/NY-East-Moriches/r_4482/</url><latitude>40.795351</latitude><longitude>-72.75636</longitude></region><region><id>41622</id><name>West Bay Shore</name><zindex currency="USD">386000</zindex><url>http://www.zillow.com/local-info/NY-West-Bay-Shore/r_41622/</url><latitude>40.710257</latitude><longitude>-73.267346</longitude></region><region><id>21494</id><name>Blue Point</name><zindex currency="USD">326800</zindex><url>http://www.zillow.com/local-info/NY-Blue-Point/r_21494/</url><latitude>40.748979</latitude><longitude>-73.033377</longitude></region><region><id>25789</id><name>Mattituck</name><zindex currency="USD">463600</zindex><url>http://www.zillow.com/local-info/NY-Mattituck/r_25789/</url><latitude>41.005613</latitude><longitude>-72.545789</longitude></region><region><id>4983</id><name>Greenport</name><zindex currency="USD">384500</zindex><url>http://www.zillow.com/local-info/NY-Greenport/r_4983/</url><latitude>41.09434</latitude><longitude>-72.373747</longitude></region><region><id>396086</id><name>East Hampton North</name><zindex currency="USD">788300</zindex><url>http://www.zillow.com/local-info/NY-East-Hampton-North/r_396086/</url><latitude>40.97429</latitude><longitude>-72.188153</longitude></region><region><id>55123</id><name>West Sayville</name><zindex currency="USD">339800</zindex><url>http://www.zillow.com/local-info/NY-West-Sayville/r_55123/</url><latitude>40.731104</latitude><longitude>-73.099722</longitude></region><region><id>35276</id><name>Cold Spring Harbor</name><zindex currency="USD">896800</zindex><url>http://www.zillow.com/local-info/NY-Cold-Spring-Harbor/r_35276/</url><latitude>40.8588</latitude><longitude>-73.452862</longitude></region><region><id>30093</id><name>Cutchogue</name><zindex currency="USD">547700</zindex><url>http://www.zillow.com/local-info/NY-Cutchogue/r_30093/</url><latitude>41.012521</latitude><longitude>-72.479086</longitude></region><region><id>42871</id><name>Lloyd Harbor</name><zindex currency="USD">1409100</zindex><url>http://www.zillow.com/local-info/NY-Lloyd-Harbor/r_42871/</url><latitude>40.911175</latitude><longitude>-73.462952</longitude></region><region><id>39866</id><name>Moriches</name><zindex currency="USD">230900</zindex><url>http://www.zillow.com/local-info/NY-Moriches/r_39866/</url><latitude>40.805158</latitude><longitude>-72.820483</longitude></region><region><id>3835</id><name>Brookhaven</name><zindex currency="USD">284400</zindex><url>http://www.zillow.com/local-info/NY-Brookhaven/r_3835/</url><latitude>40.762512</latitude><longitude>-72.911245</longitude></region><region><id>25276</id><name>Islandia</name><zindex currency="USD">277500</zindex><url>http://www.zillow.com/local-info/NY-Islandia/r_25276/</url><latitude>40.805098</latitude><longitude>-73.17394</longitude></region><region><id>49030</id><name>Eastport</name><zindex currency="USD">342900</zindex><url>http://www.zillow.com/local-info/NY-Eastport/r_49030/</url><latitude>40.827443</latitude><longitude>-72.72184</longitude></region><region><id>196835</id><name>Northwest Harbor</name><zindex currency="USD">964100</zindex><url>http://www.zillow.com/local-info/NY-Northwest-Harbor/r_196835/</url><latitude>41.007525</latitude><longitude>-72.227362</longitude></region><region><id>12802</id><name>Montauk</name><zindex currency="USD">748500</zindex><url>http://www.zillow.com/local-info/NY-Montauk/r_12802/</url><latitude>41.042604</latitude><longitude>-71.95601</longitude></region><region><id>30598</id><name>Brightwaters</name><zindex currency="USD">422000</zindex><url>http://www.zillow.com/local-info/NY-Brightwaters/r_30598/</url><latitude>40.716736</latitude><longitude>-73.261533</longitude></region><region><id>48451</id><name>Westhampton</name><zindex currency="USD">654900</zindex><url>http://www.zillow.com/local-info/NY-Westhampton/r_48451/</url><latitude>40.828096</latitude><longitude>-72.676253</longitude></region><region><id>55987</id><name>Halesite</name><zindex currency="USD">477300</zindex><url>http://www.zillow.com/local-info/NY-Halesite/r_55987/</url><latitude>40.87084</latitude><longitude>-73.413501</longitude></region><region><id>196848</id><name>Noyack</name><zindex currency="USD">635500</zindex><url>http://www.zillow.com/local-info/NY-Noyack/r_196848/</url><latitude>40.991394</latitude><longitude>-72.338681</longitude></region><region><id>47499</id><name>Sag Harbor</name><zindex currency="USD">724500</zindex><url>http://www.zillow.com/local-info/NY-Sag-Harbor/r_47499/</url><latitude>41.011437</latitude><longitude>-72.322571</longitude></region><region><id>7774</id><name>Water Mill</name><zindex currency="USD">2268200</zindex><url>http://www.zillow.com/local-info/NY-Water-Mill/r_7774/</url><latitude>40.931315</latitude><longitude>-72.340748</longitude></region><region><id>198622</id><name>Village of the Branch</name><zindex currency="USD">456100</zindex><url>http://www.zillow.com/local-info/NY-Village-of-the-Branch/r_198622/</url><latitude>40.854559</latitude><longitude>-73.185669</longitude></region><region><id>12990</id><name>Nissequogue</name><zindex currency="USD">848300</zindex><url>http://www.zillow.com/local-info/NY-Nissequogue/r_12990/</url><latitude>40.902636</latitude><longitude>-73.189142</longitude></region><region><id>14585</id><name>Westhampton Beach</name><zindex currency="USD">730500</zindex><url>http://www.zillow.com/local-info/NY-Westhampton-Beach/r_14585/</url><latitude>40.808214</latitude><longitude>-72.647329</longitude></region><region><id>396689</id><name>Huntington</name><zindex currency="USD">400400</zindex><url>http://www.zillow.com/local-info/NY-Huntington/r_396689/</url><latitude>40.836505</latitude><longitude>-73.382846</longitude></region><region><id>39376</id><name>Laurel</name><zindex currency="USD">464300</zindex><url>http://www.zillow.com/local-info/NY-Laurel/r_39376/</url><latitude>40.966349</latitude><longitude>-72.557466</longitude></region><region><id>397701</id><name>Town of Shelter Island</name><zindex currency="USD">678800</zindex><url>http://www.zillow.com/local-info/NY-Town-of-Shelter-Island/r_397701/</url><latitude>41.057936</latitude><longitude>-72.312468</longitude></region><region><id>11849</id><name>Head of the Harbor</name><zindex currency="USD">814800</zindex><url>http://www.zillow.com/local-info/NY-Head-of-the-Harbor/r_11849/</url><latitude>40.894953</latitude><longitude>-73.161765</longitude></region><region><id>18662</id><name>Huntington Bay</name><zindex currency="USD">863200</zindex><url>http://www.zillow.com/local-info/NY-Huntington-Bay/r_18662/</url><latitude>40.903177</latitude><longitude>-73.4113</longitude></region><region><id>28468</id><name>Eatons Neck</name><zindex currency="USD">636600</zindex><url>http://www.zillow.com/local-info/NY-Eatons-Neck/r_28468/</url><latitude>40.929128</latitude><longitude>-73.406112</longitude></region><region><id>395435</id><name>Islip</name><url>http://www.zillow.com/local-info/NY-Islip/r_395435/</url><latitude>40.713159</latitude><longitude>-73.186578</longitude></region><region><id>41356</id><name>Upton</name><url>http://www.zillow.com/local-info/NY-Upton/r_41356/</url><latitude>40.866848</latitude><longitude>-72.86924</longitude></region><region><id>38288</id><name>East Hampton</name><zindex currency="USD">2009100</zindex><url>http://www.zillow.com/local-info/NY-East-Hampton/r_38288/</url><latitude>40.949814</latitude><longitude>-72.197685</longitude></region><region><id>30203</id><name>Amagansett</name><zindex currency="USD">1451900</zindex><url>http://www.zillow.com/local-info/NY-Amagansett/r_30203/</url><latitude>40.990879</latitude><longitude>-72.093184</longitude></region><region><id>47195</id><name>Poquott</name><url>http://www.zillow.com/local-info/NY-Poquott/r_47195/</url><latitude>40.952524</latitude><longitude>-73.089327</longitude></region><region><id>26286</id><name>Old Field</name><url>http://www.zillow.com/local-info/NY-Old-Field/r_26286/</url><latitude>40.961258</latitude><longitude>-73.124577</longitude></region><region><id>35369</id><name>East Marion</name><zindex currency="USD">495300</zindex><url>http://www.zillow.com/local-info/NY-East-Marion/r_35369/</url><latitude>41.126667</latitude><longitude>-72.339215</longitude></region><region><id>40480</id><name>Quioque</name><url>http://www.zillow.com/local-info/NY-Quioque/r_40480/</url><latitude>40.817291</latitude><longitude>-72.628082</longitude></region><region><id>56373</id><name>North Haven</name><zindex currency="USD">1101100</zindex><url>http://www.zillow.com/local-info/NY-North-Haven/r_56373/</url><latitude>41.022005</latitude><longitude>-72.315159</longitude></region><region><id>33971</id><name>Shelter Island Heights</name><zindex currency="USD">715400</zindex><url>http://www.zillow.com/local-info/NY-Shelter-Island-Heights/r_33971/</url><latitude>41.073987</latitude><longitude>-72.331625</longitude></region><region><id>19775</id><name>Orient</name><zindex currency="USD">616800</zindex><url>http://www.zillow.com/local-info/NY-Orient/r_19775/</url><latitude>41.158508</latitude><longitude>-72.212676</longitude></region><region><id>47500</id><name>Sagaponack</name><zindex currency="USD">4015500</zindex><url>http://www.zillow.com/local-info/NY-Sagaponack/r_47500/</url><latitude>40.935123</latitude><longitude>-72.275419</longitude></region><region><id>37355</id><name>Belle Terre</name><url>http://www.zillow.com/local-info/NY-Belle-Terre/r_37355/</url><latitude>40.960372</latitude><longitude>-73.068657</longitude></region><region><id>43952</id><name>Asharoken</name><url>http://www.zillow.com/local-info/NY-Asharoken/r_43952/</url><latitude>40.93686</latitude><longitude>-73.375871</longitude></region><region><id>35956</id><name>Peconic</name><url>http://www.zillow.com/local-info/NY-Peconic/r_35956/</url><latitude>41.036115</latitude><longitude>-72.465521</longitude></region><region><id>28999</id><name>Remsenburg</name><url>http://www.zillow.com/local-info/NY-Remsenburg/r_28999/</url><latitude>40.80802</latitude><longitude>-72.706688</longitude></region><region><id>38782</id><name>Great River</name><url>http://www.zillow.com/local-info/NY-Great-River/r_38782/</url><latitude>40.723318</latitude><longitude>-73.151621</longitude></region><region><id>396696</id><name>Gilgo-Oak Beach-Captree</name><url>http://www.zillow.com/local-info/NY-Gilgo--Oak-Beach--Captree/r_396696/</url><latitude>40.635022</latitude><longitude>-73.333387</longitude></region><region><id>50196</id><name>Quogue</name><zindex currency="USD">1581700</zindex><url>http://www.zillow.com/local-info/NY-Quogue/r_50196/</url><latitude>40.818456</latitude><longitude>-72.603067</longitude></region><region><id>18108</id><name>Fishers Island</name><zindex currency="USD">864900</zindex><url>http://www.zillow.com/local-info/NY-Fishers-Island/r_18108/</url><latitude>41.270904</latitude><longitude>-71.980214</longitude></region><region><id>53555</id><name>New Suffolk</name><url>http://www.zillow.com/local-info/NY-New-Suffolk/r_53555/</url><latitude>40.976952</latitude><longitude>-72.466276</longitude></region><region><id>21129</id><name>Wainscott</name><url>http://www.zillow.com/local-info/NY-Wainscott/r_21129/</url><latitude>40.939709</latitude><longitude>-72.247103</longitude></region><region><id>36840</id><name>Bridgehampton</name><zindex currency="USD">1367200</zindex><url>http://www.zillow.com/local-info/NY-Bridgehampton/r_36840/</url><latitude>40.938163</latitude><longitude>-72.29805</longitude></region><region><id>55144</id><name>Westhampton Dunes</name><url>http://www.zillow.com/local-info/NY-Westhampton-Dunes/r_55144/</url><latitude>40.773844</latitude><longitude>-72.7242</longitude></region><region><id>194224</id><name>Dering Harbor</name><url>http://www.zillow.com/local-info/NY-Dering-Harbor/r_194224/</url><latitude>41.093396</latitude><longitude>-72.342143</longitude></region><region><id>40122</id><name>Ocean Beach</name><url>http://www.zillow.com/local-info/NY-Ocean-Beach/r_40122/</url><latitude>40.644516</latitude><longitude>-73.161975</longitude></region><region><id>6912</id><name>Saltaire</name><url>http://www.zillow.com/local-info/NY-Saltaire/r_6912/</url><latitude>40.638696</latitude><longitude>-73.194847</longitude></region><region><id>20567</id><name>South Jamesport</name><url>http://www.zillow.com/local-info/NY-South-Jamesport/r_20567/</url><latitude>40.937024</latitude><longitude>-72.574802</longitude></region></list></response></RegionChildren:regionchildren><!-- H:019 T:517ms S:16466 R:Thu Nov 15 20:19:52 PST 2012 B:3.0.173361.20121115132217999-comp_rel_a -->' towns = [] root = etree.fromstring(sample) for element in root.iter('region'): regionid = name = county = avgprice = url = latitude = longitude = '' for child in element: if child.tag == 'id': regionid = child.text elif child.tag == 'name': name = child.text elif child.tag == 'zindex': avgprice = child.text elif child.tag == 'url': url = child.text elif child.tag == 'latitude': latitude = child.text elif child.tag == 'longitude': longitude = child.text if name != '': town = Town(regionid, name, 'suffolk', avgprice, url, latitude, longitude) print town #print element.text