-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
59 lines (45 loc) · 1.67 KB
/
app.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
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
import time
import requests
from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
from fit_checker import evaluate_job_fit
from get_job_detail import get_job_detail
from to_word import to_word
# Set up Selenium WebDriver
driver = webdriver.Chrome() # or webdriver.Firefox() if you're using Firefox
driver.get('https://www.kforce.com/find-work/search-jobs/#/?t=Java&l=%5B%5D')
# Click "Load more" until it no longer appears
while True:
try:
driver.find_element("xpath", "//span[@class='btn-line-darkCerulean' and text()='Load more']").click()
time.sleep(2) # Wait for the next set of jobs to load
except:
break # Exit the loop when the "Load more" button is no longer found
# Get the page source and parse it with BeautifulSoup
soup = BeautifulSoup(driver.page_source, 'html.parser')
# Close the Selenium WebDriver
driver.quit()
# Find all job links
job_links = soup.find_all('a', class_='linkForJob')
# List to store job data
jobs = []
# Iterate over each job link
for job_link in job_links:
# Extract the href attribute
job_href = job_link['href']
# Construct the full URL
job_url = 'https://www.kforce.com/find-work/search-jobs/' + job_href
try:
job_data = get_job_detail(job_url)
except:
print("Error")
print(job_url)
continue
job_description = job_data['Description']
job_title = job_data['Title']
fit_checker = evaluate_job_fit(job_description)
if fit_checker:
jobs.append({ 'Link': job_url, 'Description': job_description, 'Title': job_title })
to_word(jobs)
print("Job titles, links, and descriptions have been exported to kforce_jobs_details.xlsx")