mirror of
https://github.com/Bunsly/JobSpy.git
synced 2026-03-06 04:24:30 -08:00
refactor(jobs): switch bad response handling to use fastapi.HTTPException
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import json
|
||||
import re
|
||||
import json
|
||||
from math import ceil
|
||||
|
||||
import tls_client
|
||||
from bs4 import BeautifulSoup
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from api.core.scrapers import Scraper, ScraperInput, Site
|
||||
from api.core.jobs import *
|
||||
from api.core.utils import handle_response
|
||||
from api.core.scrapers import Scraper, ScraperInput, Site
|
||||
|
||||
|
||||
class IndeedScraper(Scraper):
|
||||
@@ -29,9 +29,11 @@ class IndeedScraper(Scraper):
|
||||
}
|
||||
|
||||
response = session.get(self.url, params=params)
|
||||
success, result = handle_response(response)
|
||||
if not success:
|
||||
return result
|
||||
if response.status_code != status.HTTP_200_OK:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Response returned {response.status_code} {response.reason}",
|
||||
)
|
||||
|
||||
soup = BeautifulSoup(response.content, "html.parser")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user