Skip to content
Permalink
Browse files

Improvements to new listings and wrong true falses

  • Loading branch information
jacksongs committed Mar 29, 2015
1 parent 70a7273 commit 9fd54c1fddee552cc505b0eee2fa6a693f260186
Showing with 8 additions and 4 deletions.
  1. +8 −4 scraper.py
@@ -229,8 +229,12 @@
snatch = []
# first let's save the listing if it is a new house
if lastlisting == []:
scraperwiki.sqlite.save(unique_keys=["Link"],data=listing,table_name='listings')
scraperwiki.sqlite.save(unique_keys=[],data={"Updated":datetime.datetime.now(),"Change":"New Listing","Old value":None,"New value":None,"Link":listing["Link"]},table_name='changes')
# First we'll check if it's a multi-suburb house.
multilisting = scraperwiki.sql.select("* from listings where Link=? order by 'Updated' desc limit 1",(listing["Link"]))
if multilisting == []
# Now we'll save it
scraperwiki.sqlite.save(unique_keys=["Link"],data=listing,table_name='listings')
scraperwiki.sqlite.save(unique_keys=[],data={"Updated":datetime.datetime.now(),"Change":"New Listing","Old value":None,"New value":None,"Link":listing["Link"]},table_name='changes')

# or if there are records listed, let's see if they have changed
else:
@@ -246,11 +250,11 @@
elif listing[l] == True:
if 1 != lastlisting[0][l]:
snatch.append(l)
scraperwiki.sqlite.save(unique_keys=[],data={"Updated":datetime.datetime.now(),"Change":l,"Old value":True,"New value":False,"Link":listing["Link"]},table_name='changes')
scraperwiki.sqlite.save(unique_keys=[],data={"Updated":datetime.datetime.now(),"Change":l,"Old value":False,"New value":True,"Link":listing["Link"]},table_name='changes')
elif listing[l] == False:
if 0 != lastlisting[0][l]:
snatch.append(l)
scraperwiki.sqlite.save(unique_keys=[],data={"Updated":datetime.datetime.now(),"Change":l,"Old value":False,"New value":True,"Link":listing["Link"]},table_name='changes')
scraperwiki.sqlite.save(unique_keys=[],data={"Updated":datetime.datetime.now(),"Change":l,"Old value":True,"New value":False,"Link":listing["Link"]},table_name='changes')
elif listing[l] != lastlisting[0][l]:
snatch.append(l)
scraperwiki.sqlite.save(unique_keys=[],data={"Updated":datetime.datetime.now(),"Change":l,"Old value":lastlisting[0][l],"New value":listing[l],"Link":listing["Link"]},table_name='changes')

0 comments on commit 9fd54c1

Please sign in to comment.
You can’t perform that action at this time.