- redfin city support

- test case updates
- types addition
- docs grammar
This commit is contained in:
Zachary Hampton
2023-09-16 13:39:03 -07:00
parent 2d6e746ae9
commit 5ea0fa0bdb
6 changed files with 43 additions and 15 deletions

View File

@@ -36,7 +36,13 @@ class RealtorScraper(Scraper):
return response_json['autocomplete'][0]
def search(self):
location_info = self.handle_location()
location_type = location_info['area_type']
"""
property types:
apartment + building + commercial + condo_townhome + condo_townhome_rowhome_coop + condos + coop + duplex_triplex + farm + investment + land + mobile + multi_family + rental + single_family + townhomes
"""
print('a')

View File

@@ -14,10 +14,18 @@ class RedfinScraper(Scraper):
response = self.session.get(url)
response_json = json.loads(response.text.replace('{}&&', ''))
def get_region_type(match_type: str):
if match_type == "4":
return "2"
elif match_type == "2":
return "6"
if response_json['payload']['exactMatch'] is not None:
return response_json['payload']['exactMatch']['id'].split('_')[1]
target = response_json['payload']['exactMatch']
else:
return response_json['payload']['sections'][0]['rows'][0].split('_')[1]
target = response_json['payload']['sections'][0]['rows'][0]
return target['id'].split('_')[1], get_region_type(target['type'])
@staticmethod
def parse_home(home: dict) -> Property:
@@ -50,9 +58,9 @@ class RedfinScraper(Scraper):
)
def search(self):
region_id = self.handle_location()
region_id, region_type = self.handle_location()
url = 'https://www.redfin.com/stingray/api/gis?al=1&region_id={}&region_type=2'.format(region_id)
url = 'https://www.redfin.com/stingray/api/gis?al=1&region_id={}&region_type={}'.format(region_id, region_type)
response = self.session.get(url)
response_json = json.loads(response.text.replace('{}&&', ''))

View File

@@ -33,3 +33,5 @@ class Property:
price_per_square_foot: int | None = None
price: int | None = None
mls_id: str | None = None
property_type: str | None = None