mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Job fetching (#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>
This commit is contained in:
parent
6822d1afeb
commit
a46b5559e0
23
web_programming/fetch_jobs.py
Normal file
23
web_programming/fetch_jobs.py
Normal file
@ -0,0 +1,23 @@
|
||||
"""
|
||||
Scraping jobs given job title and location from indeed website
|
||||
"""
|
||||
from typing import Generator, Tuple
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
url = "https://www.indeed.co.in/jobs?q=mobile+app+development&l="
|
||||
|
||||
|
||||
def fetch_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
|
||||
for job in soup.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()
|
||||
yield job_title, company_name
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
for i, job in enumerate(fetch_jobs("Bangalore"), 1):
|
||||
print(f"Job {i:>2} is {job[0]} at {job[1]}")
|
Loading…
Reference in New Issue
Block a user