Spaces:
Build error
Build error
File size: 2,347 Bytes
155ad11 7b4cd16 155ad11 fe90369 fe67714 7b4cd16 b48634d bbf3f7d fe67714 ef649e8 fe90369 7b4cd16 fe67714 ef649e8 7b4cd16 fe90369 155ad11 0cf2985 155ad11 fe90369 155ad11 fe90369 155ad11 fe90369 155ad11 0cf2985 155ad11 a52afbe 155ad11 0cf2985 155ad11 | 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 | import gradio as gr
import logging
import pandas as pd
from jobspy import scrape_jobs
# Configure logging
logging.basicConfig(filename="job_scraper.log", level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
# Scraper function
def scrape_jobs_func(query, locations, time_filter, country):
hrs = 0
if time_filter=="From Past Week":
hrs = 168
else:
hrs = 72
jobs = scrape_jobs(
site_name=["linkedin", "glassdoor", "naukri", "google", "indeed"],
search_term= f"{query} job at {locations}",
google_search_term= f"{query} job at {locations}",
location= f"{locations}",
results_wanted=3,
hours_old=hrs,
country_indeed = f"{country}"
)
message = f"Found {len(jobs)} jobs"
initial_df = pd.DataFrame(jobs)
df = initial_df[['site','title','company','location','date_posted','is_remote','job_url','description']]
return df, message
def gradio_interface(query, locations, time_filter, country):
df, message = scrape_jobs_func(query, locations, time_filter, country)
return df, message
custom_css = """
.big-table .wrap.svelte-1ipelgc {
max-width: 100% !important;
overflow-x: auto;
}
.big-table table {
min-width: 1000px; /* Adjust width as needed */
}
"""
# App Layout
iface = gr.Interface(
fn=gradio_interface,
inputs=[
gr.Textbox(label="Job Query", placeholder="e.g., Data Scientist", value="Software Engineer"),
gr.Textbox(label="Location", placeholder="e.g., Delhi, Bangalore", value="Bangalore"),
gr.Dropdown(
label="Time Filter",
choices=["From Past Week", "From Past 3 Days"],
value="From Past 3 Days", # Default option
type="value",
),
gr.Dropdown(
label="Country",
choices=["India", "USA", "Canada", "UK", "Australia"],
value="India",
type="value"
)
],
outputs=[
gr.Dataframe(label="Job Results", headers=['Date','Company', 'ApplyLink'], interactive=True, elem_classes="big-table"),
gr.Textbox(label="Message"),
],
#title="Job Scraper",
description="Enter a job query and locations to scrape job postings and display the results in a table.",
css=custom_css
)
if __name__ == "__main__":
iface.launch() |