Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(li): job function #160

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ work with us.*
- Aggregates the job postings in a Pandas DataFrame
- Proxies support

[Video Guide for JobSpy](https://www.youtube.com/watch?v=RuP1HrAZnxs&pp=ygUgam9icyBzY3JhcGVyIGJvdCBsaW5rZWRpbiBpbmRlZWQ%3D) -
Updated for release v1.1.3

![jobspy](https://github.com/cullenwatson/JobSpy/assets/78247585/ec7ef355-05f6-4fd3-8161-a817e31c5c57)

### Installation
Expand Down Expand Up @@ -46,7 +43,7 @@ jobs = scrape_jobs(
)
print(f"Found {len(jobs)} jobs")
print(jobs.head())
jobs.to_csv("jobs.csv", quoting=csv.QUOTE_NONNUMERIC, escapechar="\\", index=False) # to_xlsx
jobs.to_csv("jobs.csv", quoting=csv.QUOTE_NONNUMERIC, escapechar="\\", index=False) # to_excel
```

### Output
Expand Down
1 change: 1 addition & 0 deletions src/jobspy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def worker(site):
"max_amount",
"currency",
"is_remote",
"job_function",
"emails",
"description",
"company_url",
Expand Down
3 changes: 3 additions & 0 deletions src/jobspy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ class JobPost(BaseModel):
logo_photo_url: str | None = None
banner_photo_url: str | None = None

# linkedin only atm
job_function: str | None = None


class JobResponse(BaseModel):
jobs: list[JobPost] = []
16 changes: 15 additions & 1 deletion src/jobspy/scrapers/linkedin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def _process_job(
job_url_direct=job_details.get("job_url_direct"),
emails=extract_emails_from_text(job_details.get("description")),
logo_photo_url=job_details.get("logo_photo_url"),
job_function=job_details.get("job_function"),
)

def _get_id(self, url: str):
Expand All @@ -247,7 +248,7 @@ def _get_job_details(self, job_page_url: str) -> dict:
response.raise_for_status()
except:
return {}
if response.url == "https://www.linkedin.com/signup":
if "linkedin.com/signup" in response.url:
return {}

soup = BeautifulSoup(response.text, "html.parser")
Expand All @@ -266,13 +267,26 @@ def remove_attributes(tag):
description = div_content.prettify(formatter="html")
if self.scraper_input.description_format == DescriptionFormat.MARKDOWN:
description = markdown_converter(description)

h3_tag = soup.find(
"h3", text=lambda text: text and "Job function" in text.strip()
)

job_function = None
if h3_tag:
job_function_span = h3_tag.find_next(
"span", class_="description__job-criteria-text"
)
if job_function_span:
job_function = job_function_span.text.strip()
return {
"description": description,
"job_type": self._parse_job_type(soup),
"job_url_direct": self._parse_job_url_direct(soup),
"logo_photo_url": soup.find("img", {"class": "artdeco-entity-image"}).get(
"data-delayed-url"
),
"job_function": job_function,
}

def _get_location(self, metadata_card: Optional[Tag]) -> Location:
Expand Down
Loading