-
Notifications
You must be signed in to change notification settings - Fork 0
/
main02.py
59 lines (42 loc) · 1.99 KB
/
main02.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 requests
from bs4 import BeautifulSoup
import time
def find_jobs():
print("Put some skill that you are not familiar with : ")
unfimiliar_skill = input("> ")
print(f"Filtering out {unfimiliar_skill} ... ")
url = "https://www.timesjobs.com/candidate/job-search.html?searchType=personalizedSearch&from=submit&txtKeywords=python&txtLocation="
html_text = requests.get(url)
Soup = BeautifulSoup(html_text.text, "lxml")
Jobs = Soup.find_all("li", class_="clearfix job-bx wht-shd-bx")
for index, job in enumerate(Jobs):
# When the job was posted
published_date = job.find("span", class_="sim-posted").span.text
if "few" in published_date:
# Name of the company
company_name = job.find("h3", class_="joblist-comp-name").text.strip()
# Position for which job is open
position = job.find("h2").find("a").text
# Skills for the job
skills = job.find("span", class_="srp-skills").text.replace(" ", "").replace(" ", "")
# Link for applying
apply_link = job.find("header").find("h2").a["href"]
if unfimiliar_skill not in skills:
with open(f"posts/{index}.txt", "w") as f:
# print(f"Company Name : {company_name.strip()}")
# print(f"Required Skills : {skills.strip()}")
# print(f"Apply link : {apply_link} ")
#
f.write(f"Company Name : {company_name.strip()} \n")
f.write(f"Required Skills : {skills.strip()} \n ")
f.write(f"Apply link : {apply_link} \n ")
print("File saved : ", index)
if __name__ == "__main__":
while True:
# Running the function to extract the jobs
find_jobs()
# Wait time to fetch data after 10 minutes
time_wait = 10
print("Waiting ", time_wait, " minutes ... ")
# Waiting for 10 minutes
time.sleep(time_wait * 60)