Skip to content

Commit

Permalink
fix None issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cullenwatson committed Aug 27, 2023
1 parent 122b332 commit 819c22e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ jobs:
echo "${response::-3}" > response.json
cat response.json
# - name: Check error field in response
# run: |
# indeed_error=$(jq '.indeed.error' response.json)
# linkedin_error=$(jq '.linkedin.error' response.json)
# zip_recruiter_error=$(jq '.zip_recruiter.error' response.json)
#
# if [[ "$indeed_error" != "null" || "$linkedin_error" != "null" || "$zip_recruiter_error" != "null" ]]; then
# echo "Error found in response:"
# echo "Indeed Error: $indeed_error"
# echo "LinkedIn Error: $linkedin_error"
# echo "ZipRecruiter Error: $zip_recruiter_error"
# exit 1
# fi
- name: Check error field in response
run: |
indeed_error=$(jq '.indeed.error' response.json)
linkedin_error=$(jq '.linkedin.error' response.json)
zip_recruiter_error=$(jq '.zip_recruiter.error' response.json)
if [[ "$indeed_error" != "null" || "$linkedin_error" != "null" || "$zip_recruiter_error" != "null" ]]; then
echo "Error found in response:"
echo "Indeed Error: $indeed_error"
echo "LinkedIn Error: $linkedin_error"
echo "ZipRecruiter Error: $zip_recruiter_error"
exit 1
fi
- name: Verify returned_results in response
run: |
Expand Down
8 changes: 5 additions & 3 deletions api/core/scrapers/ziprecruiter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def process_job(job: Tag) -> Optional[JobPost]:
title = job.find("h2", {"class": "title"}).text
company = job.find("a", {"class": "company_name"}).text.strip()

description, job_url = ZipRecruiterScraper.get_description(job_url, session)
description, updated_job_url = ZipRecruiterScraper.get_description(job_url, session)
if updated_job_url is not None:
job_url = updated_job_url
if description is None:
description = job.find("p", {"class": "job_snippet"}).text.strip()

Expand Down Expand Up @@ -185,7 +187,7 @@ def scrape(self, scraper_input: ScraperInput) -> JobResponse:
@staticmethod
def get_description(
job_page_url: str, session: tls_client.Session
) -> Tuple[Optional[str], str]:
) -> Tuple[Optional[str], Optional[str]]:
"""
Retrieves job description by going to the job page url
:param job_page_url:
Expand All @@ -196,7 +198,7 @@ def get_description(
job_page_url, headers=ZipRecruiterScraper.headers(), allow_redirects=True
)
if response.status_code not in range(200, 400):
return None
return None, None

html_string = response.content
soup_job = BeautifulSoup(html_string, "html.parser")
Expand Down

0 comments on commit 819c22e

Please sign in to comment.