Automating Job Search Notifications with Python
In today’s fast-paced job market, keeping an eye out for the latest job postings can be a full-time job in itself. Automating the process can save you time and ensure you never miss out on a great opportunity. In this blog, I’ll walk you through a Python script designed to search for job listings from popular job sites like Seek and Indeed, and automatically send you an email notification when new jobs are found. The script can be customised to fit your specific job search criteria and preferences.
Prerequisites
Before diving into the script, ensure you have Python installed on your system along with the necessary libraries. You can install the required packages using pip:
1
pip install requests beautifulsoup4
The Script Breakdown
Setting Up Job Search Parameters
The script begins by defining the keywords and location for the job search. These parameters can be adjusted to match your specific requirements.
1
2
3
4
5
6
7
# Job search parameters
keywords = "Senior IT Manager"
location = "Gold Coast, QLD"
job_sites = {
"Seek": "https://www.seek.com.au/jobs-in-information-communication-technology/management/in-All-Gold-Coast-QLD",
"Indeed": "https://au.indeed.com/jobs?q=system+administrator&l=Gold+Coast+QLD",
}
You can add more job sites to the job_sites dictionary if needed.
Email Configuration
Next, configure the email details that will be used to send job notifications. Make sure to replace the placeholder values with your actual email credentials.
1
2
3
4
5
# Email details
email_sender = '[email protected]'
email_password = 'password'
email_receiver = '[email protected]'
email_subject = "New Job Listing in Gold Coast"
Tracking Emailed Jobs
To avoid sending duplicate job listings, the script tracks jobs that have already been emailed. It stores these in a text file (emailed_jobs.txt), which is loaded at the start and updated after new jobs are found.
1
2
3
4
5
6
7
8
9
# File to track emailed jobs
emailed_jobs_file = 'emailed_jobs.txt'
# Function to load emailed jobs from file
def load_emailed_jobs():
if not os.path.exists(emailed_jobs_file):
return set()
with open(emailed_jobs_file, 'r') as file:
return set(line.strip() for line in file)
Scraping Job Listings
The script includes functions to scrape job listings from Seek and Indeed. It uses requests to fetch the HTML content of the job listing pages and BeautifulSoup to parse the HTML and extract relevant job information.
1
2
3
4
5
6
7
8
9
10
11
12
13
# Function to check jobs on Seek
def check_seek_jobs(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
job_listings = soup.find_all('article')
return job_listings
# Function to check jobs on Indeed
def check_indeed_jobs(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
job_listings = soup.find_all('div', class_='job_seen_beacon')
return job_listings
Sending Job Notifications
Once new jobs are identified, an email notification is composed and sent using the smtplib library. The email includes the job titles and links to the listings.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Function to send email
def send_email(job_details):
msg = MIMEMultipart()
msg['From'] = email_sender
msg['To'] = email_receiver
msg['Subject'] = email_subject
body = f"New System Administrator Job Listings:\n\n{job_details}"
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.example.com', 25)
server.starttls()
server.login(email_sender, email_password)
text = msg.as_string()
server.sendmail(email_sender, email_receiver, text)
server.quit()
Putting It All Together
The main function ties all the components together. It loads previously emailed jobs, checks for new job listings, sends an email if new jobs are found, and updates the list of emailed jobs.
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
30
31
def main():
emailed_jobs = load_emailed_jobs()
new_jobs = []
job_details = ""
for site_name, site_url in job_sites.items():
if "Seek" in site_name:
jobs = check_seek_jobs(site_url)
elif "Indeed" in site_name:
jobs = check_indeed_jobs(site_url)
if jobs:
job_details += f"\n{site_name} Listings:\n"
for job in jobs[:5]: # Limit to first 5 jobs
job_link = job.find('a')['href']
# Ensure job link is absolute
if not job_link.startswith('http'):
job_link = "https://www.seek.com.au" + job_link if "Seek" in site_name else "https://au.indeed.com" + job_link
if job_link not in emailed_jobs:
job_title = job.find('a').text.strip()
job_details += f"{job_title}\n{job_link}\n\n"
new_jobs.append(job_link)
if new_jobs:
send_email(job_details)
save_emailed_jobs(new_jobs)
if __name__ == "__main__":
main()
Conclusion
This script provides a robust foundation for automating job search notifications. It can be expanded to include more job sites or even customised to search for different roles or locations. By running this script regularly, you can stay ahead of the competition and be the first to apply for the latest job opportunities.
The Complete Code
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import requests
from bs4 import BeautifulSoup
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import os
# Job search parameters
keywords = "Senior IT Manager"
location = "Gold Coast, QLD"
job_sites = {
"Seek": "https://www.seek.com.au/jobs-in-information-communication-technology/management/in-All-Gold-Coast-QLD",
"Indeed": "https://au.indeed.com/jobs?q=system+administrator&l=Gold+Coast+QLD",
# Add more job sites if needed
}
# Email details
email_sender = '[email protected]'
email_password = 'password'
email_receiver = '[email protected]'
email_subject = "New Job Listing in Gold Coast"
# File to track emailed jobs
emailed_jobs_file = 'emailed_jobs.txt'
# Function to load emailed jobs from file
def load_emailed_jobs():
if not os.path.exists(emailed_jobs_file):
return set()
with open(emailed_jobs_file, 'r') as file:
return set(line.strip() for line in file)
# Function to save emailed jobs to file
def save_emailed_jobs(job_links):
with open(emailed_jobs_file, 'a') as file:
for link in job_links:
file.write(f"{link}\n")
# Function to check jobs on Seek
def check_seek_jobs(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
job_listings = soup.find_all('article')
return job_listings
# Function to check jobs on Indeed
def check_indeed_jobs(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
job_listings = soup.find_all('div', class_='job_seen_beacon')
return job_listings
# Function to send email
def send_email(job_details):
msg = MIMEMultipart()
msg['From'] = email_sender
msg['To'] = email_receiver
msg['Subject'] = email_subject
body = f"New System Administrator Job Listings:\n\n{job_details}"
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp,example.com', 25)
server.starttls()
server.login(email_sender, email_password)
text = msg.as_string()
server.sendmail(email_sender, email_receiver, text)
server.quit()
# Main script to search for jobs
def main():
emailed_jobs = load_emailed_jobs()
new_jobs = []
job_details = ""
for site_name, site_url in job_sites.items():
if "Seek" in site_name:
jobs = check_seek_jobs(site_url)
elif "Indeed" in site_name:
jobs = check_indeed_jobs(site_url)
if jobs:
job_details += f"\n{site_name} Listings:\n"
for job in jobs[:5]: # Limit to first 5 jobs
job_link = job.find('a')['href']
# Ensure job link is absolute
if not job_link.startswith('http'):
job_link = "https://www.seek.com.au" + job_link if "Seek" in site_name else "https://au.indeed.com" + job_link
if job_link not in emailed_jobs:
job_title = job.find('a').text.strip()
job_details += f"{job_title}\n{job_link}\n\n"
new_jobs.append(job_link)
if new_jobs:
send_email(job_details)
save_emailed_jobs(new_jobs)
if __name__ == "__main__":
main()
If you have any questions or need further customisation, feel free to reach out in the comments below. Happy job hunting!