mirror of https://github.com/Bunsly/JobSpy
- api/jobs/v1 schema change
parent
47a8c62d44
commit
3cb8714ad7
|
@ -10,9 +10,12 @@ class Site(Enum):
|
|||
|
||||
|
||||
class ScraperInput(BaseModel):
|
||||
location: str
|
||||
site_type: Site
|
||||
|
||||
search_term: str
|
||||
location: str
|
||||
distance: int = 25
|
||||
|
||||
results_wanted: int = 15 #: TODO: implement
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from fastapi import APIRouter, Depends
|
|||
from api.core.scrapers.indeed import IndeedScraper
|
||||
from api.core.scrapers.ziprecruiter import ZipRecruiterScraper
|
||||
from api.core.scrapers.linkedin import LinkedInScraper
|
||||
from api.core.scrapers import ScraperInput, Site
|
||||
from api.core.scrapers import ScraperInput, Site, JobResponse
|
||||
|
||||
router = APIRouter(prefix="/jobs")
|
||||
|
||||
|
@ -14,16 +14,13 @@ SCRAPER_MAPPING = {
|
|||
}
|
||||
|
||||
|
||||
@router.get("/")
|
||||
@router.get("/", response_model=JobResponse)
|
||||
async def scrape_jobs(
|
||||
site_type: Site, search_term: str, location: str, page: int = 1, distance: int = 25
|
||||
scraper_input: ScraperInput
|
||||
):
|
||||
scraper_class = SCRAPER_MAPPING[site_type]
|
||||
scraper_class = SCRAPER_MAPPING[scraper_input.site_type]
|
||||
scraper = scraper_class()
|
||||
|
||||
scraper_input = ScraperInput(
|
||||
search_term=search_term, location=location, page=page, distance=distance
|
||||
)
|
||||
job_response = scraper.scrape(scraper_input)
|
||||
|
||||
return job_response
|
||||
|
|
Loading…
Reference in New Issue