mirror of https://github.com/Bunsly/JobSpy
refactor(jobs): use JobResponse model for bad requests
parent
2c6e19254e
commit
2aa8ff7302
|
@ -13,7 +13,6 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/auth/token")
|
||||||
|
|
||||||
|
|
||||||
def create_access_token(data: dict):
|
def create_access_token(data: dict):
|
||||||
print(JWT_SECRET_KEY)
|
|
||||||
to_encode = data.copy()
|
to_encode = data.copy()
|
||||||
expire = datetime.utcnow() + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
|
expire = datetime.utcnow() + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||||
to_encode.update({"exp": expire})
|
to_encode.update({"exp": expire})
|
||||||
|
|
|
@ -35,9 +35,10 @@ class IndeedScraper(Scraper):
|
||||||
|
|
||||||
response = session.get(self.url, params=params)
|
response = session.get(self.url, params=params)
|
||||||
if response.status_code != status.HTTP_200_OK:
|
if response.status_code != status.HTTP_200_OK:
|
||||||
raise HTTPException(
|
return JobResponse(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
success=False,
|
||||||
detail=f"Response returned {response.status_code}",
|
error=f"Response returned {response.status_code}",
|
||||||
|
http_response_code=response.status_code
|
||||||
)
|
)
|
||||||
|
|
||||||
soup = BeautifulSoup(response.content, "html.parser")
|
soup = BeautifulSoup(response.content, "html.parser")
|
||||||
|
|
|
@ -26,10 +26,12 @@ class LinkedInScraper(Scraper):
|
||||||
|
|
||||||
self.url = f"{self.url}/{scraper_input.search_term}-jobs"
|
self.url = f"{self.url}/{scraper_input.search_term}-jobs"
|
||||||
response = requests.get(self.url, params=params)
|
response = requests.get(self.url, params=params)
|
||||||
|
response.status_code = 300
|
||||||
if response.status_code != status.HTTP_200_OK:
|
if response.status_code != status.HTTP_200_OK:
|
||||||
raise HTTPException(
|
return JobResponse(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
success=False,
|
||||||
detail=f"Response returned {response.status_code} {response.reason}",
|
error=f"Response returned {response.status_code}",
|
||||||
|
http_response_code=response.status_code
|
||||||
)
|
)
|
||||||
|
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
|
|
|
@ -34,9 +34,10 @@ class ZipRecruiterScraper(Scraper):
|
||||||
self.url, headers=ZipRecruiterScraper.headers(), params=params
|
self.url, headers=ZipRecruiterScraper.headers(), params=params
|
||||||
)
|
)
|
||||||
if response.status_code != status.HTTP_200_OK:
|
if response.status_code != status.HTTP_200_OK:
|
||||||
raise HTTPException(
|
return JobResponse(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
success=False,
|
||||||
detail=f"Response returned {response.status_code} {response.reason}",
|
error=f"Response returned {response.status_code}",
|
||||||
|
http_response_code=response.status_code
|
||||||
)
|
)
|
||||||
|
|
||||||
html_string = response.content
|
html_string = response.content
|
||||||
|
|
Loading…
Reference in New Issue