Extract Data From JustDial using Selenium

Github repository Link: Click here

JustDial Data Extractor is the most powerful and easy-to-use python Script. User can easily get data from the websites and save it into the .csv format.

  1. Name
  2. Address
  • Selenium package: Install selenium package using the following command.
# code
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
import pandas as pd
import time
import os

# driver.get method() will navigate to a page given by the URL address
driver.get("https://www.justdial.com/Delhi/Ceiling-Tile-Dealers-Armstrong/nct-11271379")


def strings_to_num(argument):

switcher = {
'dc': '+',
'fe': '(',
'hg': ')',
'ba': '-',
'acb': '0',
'yz': '1',
'wx': '2',
'vu': '3',
'ts': '4',
'rq': '5',
'po': '6',
'nm': '7',
'lk': '8',
'ji': '9'
}
return switcher.get(argument, "nothing")

storeDetails = driver.find_elements_by_class_name('store-details')

nameList = []
addressList = []
numbersList = []

for i in range(len(storeDetails)):

name = storeDetails[i].find_element_by_class_name('lng_cont_name').text
address = storeDetails[i].find_element_by_class_name('cont_sw_addr').text
contactList = storeDetails[i].find_elements_by_class_name('mobilesv')

myList = []

for j in range(len(contactList)):

myString = contactList[j].get_attribute('class').split("-")[1]

myList.append(strings_to_num(myString))

nameList.append(name)
addressList.append(address)
numbersList.append("".join(myList))



# intialise data of lists.
data = {'Company Name':nameList,
'Address': addressList,
'Phone':numbersList}

# Create DataFrame
df = pd.DataFrame(data)
print(df)

# Save Data as .csv
df.to_csv('demo1.csv', mode='a', header=False)