HomeHarvest/homeharvest/core/scrapers/models.py

66 lines
1.5 KiB
Python
Raw Normal View History

2023-09-15 15:17:37 -07:00
from dataclasses import dataclass
from enum import Enum
2023-10-03 22:21:16 -07:00
from typing import Optional
2023-09-15 15:17:37 -07:00
2023-09-17 16:30:37 -07:00
class SiteName(Enum):
ZILLOW = "zillow"
REDFIN = "redfin"
REALTOR = "realtor.com"
@classmethod
def get_by_value(cls, value):
for item in cls:
if item.value == value:
return item
raise ValueError(f"{value} not found in {cls}")
2023-09-17 16:30:37 -07:00
2023-09-15 15:17:37 -07:00
class ListingType(Enum):
2023-09-18 11:38:17 -07:00
FOR_SALE = "FOR_SALE"
FOR_RENT = "FOR_RENT"
SOLD = "SOLD"
2023-09-15 15:17:37 -07:00
@dataclass
class Address:
2023-10-03 22:21:16 -07:00
street: str | None = None
unit: str | None = None
2023-09-19 19:13:20 -07:00
city: str | None = None
state: str | None = None
2023-10-03 22:21:16 -07:00
zip: str | None = None
2023-09-15 15:17:37 -07:00
@dataclass
2023-10-04 06:58:55 -07:00
class Description:
style: str | None = None
beds: int | None = None
baths_full: int | None = None
baths_half: int | None = None
sqft: int | None = None
lot_sqft: int | None = None
sold_price: int | None = None
year_built: int | None = None
garage: float | None = None
stories: int | None = None
2023-09-18 11:38:17 -07:00
@dataclass
class Property:
2023-10-04 06:58:55 -07:00
property_url: str
2023-10-03 22:21:16 -07:00
mls: str | None = None
2023-09-15 16:03:17 -07:00
mls_id: str | None = None
2023-10-03 22:21:16 -07:00
status: str | None = None
2023-10-04 06:58:55 -07:00
address: Address | None = None
2023-10-03 22:21:16 -07:00
list_price: int | None = None
list_date: str | None = None
last_sold_date: str | None = None
2023-10-04 06:58:55 -07:00
prc_sqft: int | None = None
2023-10-03 22:21:16 -07:00
hoa_fee: int | None = None
2023-10-04 06:58:55 -07:00
description: Description | None = None
2023-10-03 22:21:16 -07:00
2023-09-19 19:13:20 -07:00
latitude: float | None = None
longitude: float | None = None
2023-10-03 22:21:16 -07:00
neighborhoods: Optional[str] = None