0% found this document useful (0 votes)
9 views

Python Scraper

This document contains a Python script that utilizes Tkinter for a GUI application to scrape job listings from Indeed based on user input for job title and location. It fetches job data using requests and parses it with BeautifulSoup, displaying the results in a text area. The application includes error handling for input validation and data retrieval issues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python Scraper

This document contains a Python script that utilizes Tkinter for a GUI application to scrape job listings from Indeed based on user input for job title and location. It fetches job data using requests and parses it with BeautifulSoup, displaying the results in a text area. The application includes error handling for input validation and data retrieval issues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import tkinter as tk

from tkinter import messagebox


import requests
from bs4 import BeautifulSoup

# Function to scrape job listings


def scrape_jobs(job_title, location):
url = f"https://www.indeed.com/jobs?q={job_title}&l={location}"
response = requests.get(url)
if response.status_code != 200:
messagebox.showerror("Error", "Failed to retrieve data from Indeed")
return []

soup = BeautifulSoup(response.content, 'html.parser')


job_listings = soup.find_all('div', class_='jobsearch-SerpJobCard')

results = []
for job in job_listings:
title_tag = job.find('a', class_='jobtitle')
company_tag = job.find('span', class_='company')
summary_tag = job.find('div', class_='summary')

if title_tag and company_tag and summary_tag:


title = title_tag.text.strip()
company = company_tag.text.strip()
summary = summary_tag.text.strip()
results.append(f"Title: {title}\nCompany: {company}\nSummary:
{summary}\n")

return results

# Function to handle the search button click


def on_search():
job_title = job_title_entry.get()
location = location_entry.get()
if not job_title or not location:
messagebox.showwarning("Input Error", "Please enter both job title and
location")
return

results = scrape_jobs(job_title, location)


result_text.delete(1.0, tk.END)
for result in results:
result_text.insert(tk.END, result + "\n\n")

# Create the main window


root = tk.Tk()
root.title("Job Scraper")
root.geometry("600x400")
root.configure(bg="#2E2E2E")

# Create and place widgets


job_title_label = tk.Label(root, text="Job Title:", bg="#2E2E2E", fg="#39FF14",
font=("Helvetica", 12))
job_title_label.pack(pady=5)
job_title_entry = tk.Entry(root, width=50, bg="#444444", fg="#39FF14",
font=("Helvetica", 12))
job_title_entry.pack(pady=5)
location_label = tk.Label(root, text="Location:", bg="#2E2E2E", fg="#39FF14",
font=("Helvetica", 12))
location_label.pack(pady=5)
location_entry = tk.Entry(root, width=50, bg="#444444", fg="#39FF14",
font=("Helvetica", 12))
location_entry.pack(pady=5)

search_button = tk.Button(root, text="Search", command=on_search, bg="#39FF14",


fg="#2E2E2E", font=("Helvetica", 12))
search_button.pack(pady=10)

result_text = tk.Text(root, width=70, height=15, bg="#444444", fg="#39FF14",


font=("Helvetica", 12))
result_text.pack(pady=10)

# Run the application


root.mainloop()

You might also like