chore: format

pull/2/head
Cullen Watson 2023-09-18 17:04:54 -05:00
parent 588689c230
commit 8e140a0e45
2 changed files with 9 additions and 2 deletions

View File

@ -130,7 +130,9 @@ class ZillowScraper(Scraper):
home_info = result["hdpData"]["homeInfo"] home_info = result["hdpData"]["homeInfo"]
address_data = { address_data = {
"street_address": home_info["streetAddress"], "street_address": home_info["streetAddress"],
"unit": parse_address_two(home_info['unit']) if 'unit' in home_info else None, "unit": parse_address_two(home_info["unit"])
if "unit" in home_info
else None,
"city": home_info["city"], "city": home_info["city"],
"state": home_info["state"], "state": home_info["state"],
"zip_code": home_info["zipcode"], "zip_code": home_info["zipcode"],

View File

@ -4,7 +4,11 @@ import re
def parse_address_two(street_address: str): def parse_address_two(street_address: str):
if not street_address: if not street_address:
return None return None
apt_match = re.search(r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+)$", street_address, re.I) apt_match = re.search(
r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+)$",
street_address,
re.I,
)
if apt_match: if apt_match:
apt_str = apt_match.group().strip() apt_str = apt_match.group().strip()
@ -13,6 +17,7 @@ def parse_address_two(street_address: str):
else: else:
return None return None
if __name__ == "__main__": if __name__ == "__main__":
print(parse_address_two("810 E Colter St APT 32")) print(parse_address_two("810 E Colter St APT 32"))
print(parse_address_two("1234 Elm Street apt 2B")) print(parse_address_two("1234 Elm Street apt 2B"))