HomeHarvest/homeharvest/core/scrapers/__init__.py

36 lines
818 B
Python
Raw Normal View History

2023-09-15 15:17:37 -07:00
from dataclasses import dataclass
import requests
2023-09-17 13:06:31 -07:00
from .models import Property, ListingType
2023-09-15 15:17:37 -07:00
@dataclass
class ScraperInput:
location: str
listing_type: ListingType
proxy_url: str | None = None
class Scraper:
2023-09-17 13:06:31 -07:00
listing_type = ListingType.FOR_SALE
2023-09-15 15:17:37 -07:00
def __init__(self, scraper_input: ScraperInput):
self.location = scraper_input.location
self.session = requests.Session()
2023-09-17 13:06:31 -07:00
Scraper.listing_type = scraper_input.listing_type
2023-09-15 15:17:37 -07:00
if scraper_input.proxy_url:
self.session.proxies = {
"http": scraper_input.proxy_url,
"https": scraper_input.proxy_url,
}
2023-09-17 13:06:31 -07:00
def search(self) -> list[Property]:
...
2023-09-15 15:42:47 -07:00
@staticmethod
2023-09-17 13:06:31 -07:00
def _parse_home(home) -> Property:
...
2023-09-15 20:58:54 -07:00
2023-09-17 13:06:31 -07:00
def handle_location(self):
...