Parcourir la source

merge hotfix1 into branch 0.1.1

Miek Stagl il y a 5 ans
Parent
commit
aa3800b51a
2 fichiers modifiés avec 34 ajouts et 6 suppressions
  1. 5 0
      CHANGELOG
  2. 29 6
      index.py

+ 5 - 0
CHANGELOG

@@ -6,6 +6,11 @@ By default, new listings are emailed.
 Results.py outputs a quick and dirty list of properties within 25 minutes to school.
 Search critiera can only be modified in the index.py code by adding criteria to the Search class instance.
 
+[hotfix 1]  11-5-2020
+
+index.py broke on multiple instances of the word 'address' on page 2 of the georgiamls listings.  Added fix to
+set the address attribute to only the first instance of the word.
+
 FUTURE GOALS
 - add .conf file
   - Search criteria

+ 29 - 6
index.py

@@ -194,6 +194,7 @@ class MLSDATA:
         ba = bedbath[1][:-3]
         baths = ba							## IF House is present
         bedrooms = br							## IF House is present
+        address = ''
         for element in details:
           if 'sqft' in element.getText():
             sqft = element.findAll('td')[1].getText().strip()[:-5].replace(',','')
@@ -210,10 +211,12 @@ class MLSDATA:
             else:
               type = 'unknown'
           if 'Address' in element.getText():
-            address = element.findAll('td')[1]
-            street_address = list(address)[0].strip()
-            csz = list(address)[2].strip()
-            split_address = self.break_address(street_address + '|' + csz)
+            if not address:  #Prevents finding the word 'address' elsewhere in the listings
+              address = element.findAll('td')[1]
+#7              print("TEST ADDRESS: ", element)
+              street_address = list(address)[0].strip()
+              csz = list(address)[2].strip()
+              split_address = self.break_address(street_address + '|' + csz)
         description = detail_soup.find('div', {'id':'listing-remarks'}).getText().strip().replace('\t','')
         data = Property(site_name = self.mlstype,  \
 		type = type, \
@@ -442,5 +445,25 @@ if __name__ == '__main__':
 #print()
 #for listing in gmls.new_listings:
 #  print(listing.MLS, listing.address)
-
-
+#  gmls = MLSDATA('GMLS')
+#
+#  #new_properties = []
+#
+##  for county in ['Jackson']:							### FIX
+#  for county in gmls.counties:							### FIX
+#    mysearch = Search(county, type=['farm', 'house', 'land'], upper_price=525000)		### FIX
+#    mydata = gmls.getmlsdata(mysearch)
+#
+#    gmls.connectdb()
+#    gmls.dbinsert(mydata)
+#    gmls.closedb()
+#
+#  gmls.email()
+#
+#print()
+#print(str(len(gmls.new_listings)) + " new properties found!")
+#print()
+#for listing in gmls.new_listings:
+#  print(listing.MLS, listing.address)
+#
+#