- redfin finished
parent
469b703288
commit
8107103383
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
from ..types import Home, Address
|
from ..types import Home, Address
|
||||||
from .. import Scraper
|
from .. import Scraper
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
class RedfinScraper(Scraper):
|
class RedfinScraper(Scraper):
|
||||||
|
@ -19,8 +20,34 @@ class RedfinScraper(Scraper):
|
||||||
return response_json['payload']['sections'][0]['rows'][0].split('_')[1]
|
return response_json['payload']['sections'][0]['rows'][0].split('_')[1]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_home(home) -> Home:
|
def parse_home(home: dict) -> Home:
|
||||||
...
|
address = Address(
|
||||||
|
address_one=home['streetLine']['value'],
|
||||||
|
city=home['city'],
|
||||||
|
state=home['state'],
|
||||||
|
zip_code=home['zip']
|
||||||
|
)
|
||||||
|
|
||||||
|
url = 'https://www.redfin.com{}'.format(home['url'])
|
||||||
|
|
||||||
|
def get_value(key: str) -> Any | None:
|
||||||
|
if key in home and 'value' in home[key]:
|
||||||
|
return home[key]['value']
|
||||||
|
|
||||||
|
return Home(
|
||||||
|
address=address,
|
||||||
|
url=url,
|
||||||
|
beds=home['beds'] if 'beds' in home else None,
|
||||||
|
baths=home['baths'] if 'baths' in home else None,
|
||||||
|
stories=home['stories'] if 'stories' in home else None,
|
||||||
|
agent_name=get_value('listingAgent'),
|
||||||
|
description=home['listingRemarks'] if 'listingRemarks' in home else None,
|
||||||
|
year_built=get_value('yearBuilt'),
|
||||||
|
square_feet=get_value('sqFt'),
|
||||||
|
price_per_square_foot=get_value('pricePerSqFt'),
|
||||||
|
price=get_value('price'),
|
||||||
|
mls_id=get_value('mlsId')
|
||||||
|
)
|
||||||
|
|
||||||
def search(self):
|
def search(self):
|
||||||
region_id = self.handle_location()
|
region_id = self.handle_location()
|
||||||
|
|
|
@ -21,3 +21,15 @@ class Address:
|
||||||
@dataclass
|
@dataclass
|
||||||
class Home:
|
class Home:
|
||||||
address: Address
|
address: Address
|
||||||
|
url: str
|
||||||
|
|
||||||
|
beds: int | None = None
|
||||||
|
baths: int | None = None
|
||||||
|
stories: int | None = None
|
||||||
|
agent_name: str | None = None
|
||||||
|
description: str | None = None
|
||||||
|
year_built: int | None = None
|
||||||
|
square_feet: int | None = None
|
||||||
|
price_per_square_foot: int | None = None
|
||||||
|
price: int | None = None
|
||||||
|
mls_id: str | None = None
|
||||||
|
|
Loading…
Reference in New Issue