forked from TheAlgorithms/Python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_jobs.py
More file actions
Latest commit
25 lines (18 loc) · 906 Bytes
/
Copy pathfetch_jobs.py
File metadata and controls
25 lines (18 loc) · 906 Bytes
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
"""
Scraping jobs given job title and location from indeed website
"""
from __future__ importannotations
fromcollections.abcimportGenerator
importrequests
frombs4importBeautifulSoup
url="https://www.indeed.co.in/jobs?q=mobile+app+development&l="
deffetch_jobs(location: str="mumbai") ->Generator[tuple[str, str], None, None]:
soup=BeautifulSoup(requests.get(url+location).content, "html.parser")
# This attribute finds out all the specifics listed in a job
forjobinsoup.find_all("div", attrs={"data-tn-component": "organicJob"}):
job_title=job.find("a", attrs={"data-tn-element": "jobTitle"}).text.strip()
company_name=job.find("span", {"class": "company"}).text.strip()
yieldjob_title, company_name
if__name__=="__main__":
fori, jobinenumerate(fetch_jobs("Bangalore"), 1):
print(f"Job {i:>2} is {job[0]} at {job[1]}")