fix: lat/long KeyError
parent
0621b01d9a
commit
cc76e067b2
|
@ -50,7 +50,7 @@ properties.to_csv('props.csv', index=False)
|
||||||
## Output
|
## Output
|
||||||
```py
|
```py
|
||||||
>>> properties.head()
|
>>> properties.head()
|
||||||
street city ... mls_id description
|
street city ... mls_id description
|
||||||
0 420 N Scottsdale Rd Tempe ... NaN NaN
|
0 420 N Scottsdale Rd Tempe ... NaN NaN
|
||||||
1 1255 E University Dr Tempe ... NaN NaN
|
1 1255 E University Dr Tempe ... NaN NaN
|
||||||
2 1979 E Rio Salado Pkwy Tempe ... NaN NaN
|
2 1979 E Rio Salado Pkwy Tempe ... NaN NaN
|
||||||
|
|
|
@ -249,8 +249,8 @@ class RealtorScraper(Scraper):
|
||||||
unit=parse_unit(result["location"]["address"]["unit"]),
|
unit=parse_unit(result["location"]["address"]["unit"]),
|
||||||
country="USA",
|
country="USA",
|
||||||
),
|
),
|
||||||
latitude=result["location"]["address"]["coordinate"]["lat"],
|
latitude=result["location"]["address"]["coordinate"]["lat"] if result and result.get("location") and result["location"].get("address") and result["location"]["address"].get("coordinate") and "lat" in result["location"]["address"]["coordinate"] else None,
|
||||||
longitude=result["location"]["address"]["coordinate"]["lon"],
|
longitude=result["location"]["address"]["coordinate"]["lon"] if result and result.get("location") and result["location"].get("address") and result["location"]["address"].get("coordinate") and "lon" in result["location"]["address"]["coordinate"] else None,
|
||||||
site_name=self.site_name,
|
site_name=self.site_name,
|
||||||
property_url="https://www.realtor.com/realestateandhomes-detail/"
|
property_url="https://www.realtor.com/realestateandhomes-detail/"
|
||||||
+ result["property_id"],
|
+ result["property_id"],
|
||||||
|
|
|
@ -94,8 +94,8 @@ class RedfinScraper(Scraper):
|
||||||
price_per_sqft=get_value("pricePerSqFt"),
|
price_per_sqft=get_value("pricePerSqFt"),
|
||||||
price=get_value("price"),
|
price=get_value("price"),
|
||||||
mls_id=get_value("mlsId"),
|
mls_id=get_value("mlsId"),
|
||||||
latitude=home["latLong"]["latitude"] if "latLong" in home else None,
|
latitude=home["latLong"]["latitude"] if "latLong" in home and "latitude" in home["latLong"] else None,
|
||||||
longitude=home["latLong"]["longitude"] if "latLong" in home else None,
|
longitude = home["latLong"]["longitude"] if "latLong" in home and "longitude" in home["latLong"] else None
|
||||||
)
|
)
|
||||||
|
|
||||||
def _parse_building(self, building: dict) -> Property:
|
def _parse_building(self, building: dict) -> Property:
|
||||||
|
|
Loading…
Reference in New Issue