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"]
address_data = {
"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"],
"state": home_info["state"],
"zip_code": home_info["zipcode"],

View File

@ -4,7 +4,11 @@ import re
def parse_address_two(street_address: str):
if not street_address:
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:
apt_str = apt_match.group().strip()
@ -13,6 +17,7 @@ def parse_address_two(street_address: str):
else:
return None
if __name__ == "__main__":
print(parse_address_two("810 E Colter St APT 32"))
print(parse_address_two("1234 Elm Street apt 2B"))