-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscrape_jobs_old.py
29 lines (25 loc) · 1000 Bytes
/
scrape_jobs_old.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
from bs4 import BeautifulSoup
URL = "https://www.monster.com/jobs/search/?q=Software-Developer\
&where=Australia"
page = requests.get(URL)
soup = BeautifulSoup(page.content, "html.parser")
results = soup.find(id="ResultsContainer")
# Look for Python jobs
python_jobs = results.find_all("h2", string=lambda t: "python" in t.lower())
for p_job in python_jobs:
link = p_job.find("a")["href"]
print(p_job.text.strip())
print(f"Apply here: {link}\n")
# Print out all available jobs from the scraped webpage
job_elems = results.find_all("section", class_="card-content")
for job_elem in job_elems:
title_elem = job_elem.find("h2", class_="title")
company_elem = job_elem.find("div", class_="company")
location_elem = job_elem.find("div", class_="location")
if None in (title_elem, company_elem, location_elem):
continue
print(title_elem.text.strip())
print(company_elem.text.strip())
print(location_elem.text.strip())
print()