Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a46b555

Browse files
Kaif10cclauss
andauthored
Job fetching (TheAlgorithms#2219)
* Adding job scarping algorithm to web programming * Delete fetch_jobs.py * Adding Jobs Scraping to web programming * Add Python type hints Co-authored-by: Christian Clauss <cclauss@me.com>
1 parent 6822d1a commit a46b555

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎web_programming/fetch_jobs.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Scraping jobs given job title and location from indeed website
3+
"""
4+
from typing import Generator, Tuple
5+
6+
import requests
7+
from bs4 import BeautifulSoup
8+
9+
url = "https://www.indeed.co.in/jobs?q=mobile+app+development&l="
10+
11+
12+
def fetch_jobs(location: str = "mumbai") -> Generator[Tuple[str, str], None, None]:
13+
soup = BeautifulSoup(requests.get(url + location).content, "html.parser")
14+
# This attribute finds out all the specifics listed in a job
15+
for job in soup.find_all("div", attrs={"data-tn-component": "organicJob"}):
16+
job_title = job.find("a", attrs={"data-tn-element": "jobTitle"}).text.strip()
17+
company_name = job.find("span", {"class": "company"}).text.strip()
18+
yield job_title, company_name
19+
20+
21+
if __name__ == "__main__":
22+
for i, job in enumerate(fetch_jobs("Bangalore"), 1):
23+
print(f"Job {i:>2} is {job[0]} at {job[1]}")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /