mirror of
https://github.com/Bunsly/HomeHarvest.git
synced 2026-03-05 12:04:31 -08:00
Compare commits
3 Commits
e378feeefe
...
v0.4.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68a3438c6e | ||
|
|
a3c5e9060e | ||
|
|
d06595fe56 |
@@ -121,7 +121,10 @@ class RealtorScraper(Scraper):
|
|||||||
|
|
||||||
property_info = response_json["data"]["home"]
|
property_info = response_json["data"]["home"]
|
||||||
|
|
||||||
return [self.process_property(property_info)]
|
if self.return_type != ReturnType.raw:
|
||||||
|
return [self.process_property(property_info)]
|
||||||
|
else:
|
||||||
|
return [property_info]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def process_advertisers(advertisers: list[dict] | None) -> Advertisers | None:
|
def process_advertisers(advertisers: list[dict] | None) -> Advertisers | None:
|
||||||
@@ -305,15 +308,20 @@ class RealtorScraper(Scraper):
|
|||||||
)
|
)
|
||||||
elif search_type == "area": #: general search, came from a general location
|
elif search_type == "area": #: general search, came from a general location
|
||||||
query = """query Home_search(
|
query = """query Home_search(
|
||||||
$location: String!,
|
$city: String,
|
||||||
|
$county: [String],
|
||||||
|
$state_code: String,
|
||||||
|
$postal_code: String
|
||||||
$offset: Int,
|
$offset: Int,
|
||||||
) {
|
) {
|
||||||
home_search(
|
home_search(
|
||||||
query: {
|
query: {
|
||||||
%s
|
%s
|
||||||
search_location: {location: $location}
|
city: $city
|
||||||
|
county: $county
|
||||||
|
postal_code: $postal_code
|
||||||
|
state_code: $state_code
|
||||||
status: %s
|
status: %s
|
||||||
unique: true
|
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
@@ -439,7 +447,11 @@ class RealtorScraper(Scraper):
|
|||||||
|
|
||||||
else: #: general search, location
|
else: #: general search, location
|
||||||
search_variables |= {
|
search_variables |= {
|
||||||
"location": self.location,
|
"city": location_info.get("city"),
|
||||||
|
"county": location_info.get("county"),
|
||||||
|
"state_code": location_info.get("state_code"),
|
||||||
|
"postal_code": location_info.get("postal_code"),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.foreclosure:
|
if self.foreclosure:
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ _SEARCH_HOMES_DATA_BASE = """{
|
|||||||
sqft
|
sqft
|
||||||
__typename
|
__typename
|
||||||
}
|
}
|
||||||
|
photos(https: true) {
|
||||||
|
title
|
||||||
|
href
|
||||||
|
tags {
|
||||||
|
label
|
||||||
|
}
|
||||||
|
}
|
||||||
list_price
|
list_price
|
||||||
__typename
|
__typename
|
||||||
}
|
}
|
||||||
@@ -90,12 +97,17 @@ _SEARCH_HOMES_DATA_BASE = """{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tax_record {
|
tax_record {
|
||||||
|
cl_id
|
||||||
public_record_id
|
public_record_id
|
||||||
|
last_update_date
|
||||||
|
apn
|
||||||
|
tax_parcel_id
|
||||||
}
|
}
|
||||||
primary_photo(https: true) {
|
primary_photo(https: true) {
|
||||||
href
|
href
|
||||||
}
|
}
|
||||||
photos(https: true) {
|
photos(https: true) {
|
||||||
|
title
|
||||||
href
|
href
|
||||||
tags {
|
tags {
|
||||||
label
|
label
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "homeharvest"
|
name = "homeharvest"
|
||||||
version = "0.4.7"
|
version = "0.4.9"
|
||||||
description = "Real estate scraping library"
|
description = "Real estate scraping library"
|
||||||
authors = ["Zachary Hampton <zachary@bunsly.com>", "Cullen Watson <cullen@bunsly.com>"]
|
authors = ["Zachary Hampton <zachary@bunsly.com>", "Cullen Watson <cullen@bunsly.com>"]
|
||||||
homepage = "https://github.com/Bunsly/HomeHarvest"
|
homepage = "https://github.com/Bunsly/HomeHarvest"
|
||||||
|
|||||||
@@ -292,11 +292,14 @@ def test_phone_number_matching():
|
|||||||
|
|
||||||
def test_return_type():
|
def test_return_type():
|
||||||
results = {
|
results = {
|
||||||
"pandas": scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100),
|
"pandas": [scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100)],
|
||||||
"pydantic": scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100, return_type="pydantic"),
|
"pydantic": [scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100, return_type="pydantic")],
|
||||||
"raw": scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100, return_type="raw"),
|
"raw": [
|
||||||
|
scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100, return_type="raw"),
|
||||||
|
scrape_property(location="66642", listing_type="for_rent", limit=100, return_type="raw"),
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
assert isinstance(results["pandas"], pd.DataFrame)
|
assert all(isinstance(result, pd.DataFrame) for result in results["pandas"])
|
||||||
assert isinstance(results["pydantic"][0], Property)
|
assert all(isinstance(result[0], Property) for result in results["pydantic"])
|
||||||
assert isinstance(results["raw"][0], dict)
|
assert all(isinstance(result[0], dict) for result in results["raw"])
|
||||||
|
|||||||
Reference in New Issue
Block a user