chore: format
parent
588689c230
commit
8e140a0e45
|
@ -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"],
|
||||||
|
|
|
@ -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"))
|
||||||
|
|
Loading…
Reference in New Issue