JobSpy/api/core/scrapers/__init__.py

46 lines
1019 B
Python
Raw Normal View History

2023-07-11 06:24:59 -07:00
from ..jobs import *
2023-08-27 14:25:48 -07:00
from ..formatters import OutputFormat
2023-08-27 18:32:46 -07:00
from typing import List, Dict, Optional, Any
2023-07-06 17:12:01 -07:00
2023-07-11 09:02:46 -07:00
class StatusException(Exception):
def __init__(self, status_code: int):
self.status_code = status_code
2023-07-06 17:12:01 -07:00
class Site(Enum):
LINKEDIN = "linkedin"
INDEED = "indeed"
ZIP_RECRUITER = "zip_recruiter"
class ScraperInput(BaseModel):
site_type: List[Site]
2023-07-06 17:12:01 -07:00
search_term: str
2023-08-27 14:25:48 -07:00
output_format: OutputFormat = OutputFormat.JSON
2023-07-11 03:42:20 -07:00
location: str = None
distance: int = None
is_remote: bool = False
2023-07-11 06:24:59 -07:00
job_type: JobType = None
2023-08-17 13:44:52 -07:00
easy_apply: bool = None # linkedin
2023-07-10 16:04:44 -07:00
results_wanted: int = 15
2023-07-06 17:12:01 -07:00
2023-08-27 18:32:46 -07:00
class CommonResponse(BaseModel):
status: Optional[str]
error: Optional[str]
linkedin: Optional[Any] = None
indeed: Optional[Any] = None
zip_recruiter: Optional[Any] = None
2023-08-27 14:25:48 -07:00
class Scraper:
2023-08-26 03:55:59 -07:00
def __init__(self, site: Site, url: str):
2023-07-06 17:12:01 -07:00
self.site = site
2023-08-26 03:55:59 -07:00
self.url = url
2023-07-06 17:12:01 -07:00
def scrape(self, scraper_input: ScraperInput) -> JobResponse:
...