Skip to content

Instantly share code, notes, and snippets.

@Shareef-shaik
Last active January 21, 2021 09:38
Show Gist options
  • Save Shareef-shaik/36f8b1d5e59dc763137021e5ca946e0f to your computer and use it in GitHub Desktop.
Save Shareef-shaik/36f8b1d5e59dc763137021e5ca946e0f to your computer and use it in GitHub Desktop.
#import necessary packages
import time
from selenium import webdriver
import pandas as pd
import matplotlib.pyplot as plt
#create an instance of browser
driver = webdriver.Chrome()
#creating a dictionary for storing the information after scraping
jobs={"roles":[],
"companies":[],
"locations":[],
"experience":[],
"skills":[]}
#we will iterate over first 50 pages; each page contains 20 results
#for each job we will scrape the role,company, location, experience, key skills.
for i in range(50):
driver.get("https://www.naukri.com/data-scientist-jobs-{}".format(i))
time.sleep(3)
lst=driver.find_elements_by_css_selector(".jobTuple.bgWhite.br4.mb-8")
for job in lst:
driver.implicitly_wait(10)
role=job.find_element_by_css_selector("a.title.fw500.ellipsis").text
company=job.find_element_by_css_selector("a.subTitle.ellipsis.fleft").text
location=job.find_element_by_css_selector(".fleft.grey-text.br2.placeHolderLi.location").text
exp=job.find_element_by_css_selector(".fleft.grey-text.br2.placeHolderLi.experience").text
skills=job.find_element_by_css_selector(".tags.has-description").text
jobs["roles"].append(role)
jobs["companies"].append(company)
jobs["locations"].append(location)
jobs["experience"].append(exp)
jobs["skills"].append(skills)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment