parent
11a7d854f0
commit
c597a78191
|
@ -587,21 +587,28 @@ class RealtorScraper(Scraper):
|
||||||
return ", ".join(neighborhoods_list) if neighborhoods_list else None
|
return ", ".join(neighborhoods_list) if neighborhoods_list else None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_address(result: dict, search_type):
|
def handle_none_safely(address_part):
|
||||||
|
if address_part is None:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
return address_part
|
||||||
|
|
||||||
|
def _parse_address(self, result: dict, search_type):
|
||||||
if search_type == "general_search":
|
if search_type == "general_search":
|
||||||
return Address(
|
address = result['location']['address']
|
||||||
street=f"{result['location']['address']['street_number']} {result['location']['address']['street_name']} {result['location']['address']['street_suffix']}",
|
else:
|
||||||
unit=result["location"]["address"]["unit"],
|
address = result["address"]
|
||||||
city=result["location"]["address"]["city"],
|
|
||||||
state=result["location"]["address"]["state_code"],
|
|
||||||
zip=result["location"]["address"]["postal_code"],
|
|
||||||
)
|
|
||||||
return Address(
|
return Address(
|
||||||
street=f"{result['address']['street_number']} {result['address']['street_name']} {result['address']['street_suffix']}",
|
street=" ".join([
|
||||||
unit=result["address"]["unit"],
|
self.handle_none_safely(address.get('street_number')),
|
||||||
city=result["address"]["city"],
|
self.handle_none_safely(address.get('street_name')),
|
||||||
state=result["address"]["state_code"],
|
self.handle_none_safely(address.get('street_suffix')),
|
||||||
zip=result["address"]["postal_code"],
|
]).strip(),
|
||||||
|
unit=address["unit"],
|
||||||
|
city=address["city"],
|
||||||
|
state=address["state_code"],
|
||||||
|
zip=address["postal_code"],
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -50,6 +50,16 @@ def test_realtor_pending_comps():
|
||||||
assert len(set([len(result) for result in results])) == len(results)
|
assert len(set([len(result) for result in results])) == len(results)
|
||||||
|
|
||||||
|
|
||||||
|
def test_realtor_sold_past():
|
||||||
|
result = scrape_property(
|
||||||
|
location="San Diego, CA",
|
||||||
|
past_days=30,
|
||||||
|
listing_type="sold",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result is not None and len(result) > 0
|
||||||
|
|
||||||
|
|
||||||
def test_realtor_comps():
|
def test_realtor_comps():
|
||||||
result = scrape_property(
|
result = scrape_property(
|
||||||
location="2530 Al Lipscomb Way",
|
location="2530 Al Lipscomb Way",
|
||||||
|
|
Loading…
Reference in New Issue