Skip to content

Commit 1fd9c01

Browse files
committed
Add final script code
1 parent 5d64ca2 commit 1fd9c01

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

web-scraping-bs4/scrape_jobs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
5+
URL = 'https://www.monster.com/jobs/search/?q=Software-Developer&where=Australia'
6+
page = requests.get(URL)
7+
8+
soup = BeautifulSoup(page.content, 'html.parser')
9+
results = soup.find(id='ResultsContainer')
10+
11+
# Look for Python jobs
12+
python_jobs = results.find_all('h2', string=lambda text: "python" in text.lower())
13+
for p_job in python_jobs:
14+
link = p_job.find('a')['href']
15+
print(p_job.text.strip())
16+
print(f"Apply here: {link}\n")
17+
18+
# Print out all available jobs from the scraped webpage
19+
job_elems = results.find_all('section', class_='card-content')
20+
for job_elem in job_elems:
21+
title_elem = job_elem.find('h2', class_='title')
22+
company_elem = job_elem.find('div', class_='company')
23+
location_elem = job_elem.find('div', class_='location')
24+
if None in (title_elem, company_elem, location_elem):
25+
continue
26+
print(title_elem.text.strip())
27+
print(company_elem.text.strip())
28+
print(location_elem.text.strip())
29+
print()

0 commit comments

Comments
 (0)