<jupyter_start><jupyter_text>WEB SCRAPING-FLIGHT PRICE<jupyter_code># Importing Libraries
import selenium
import pandas as pd
import time
from bs4 import BeautifulSoup

# Importing selenium webdriver 
from selenium import webdriver

# Importing required Exceptions which needs to handled
from selenium.common.exceptions import StaleElementReferenceException, NoSuchElementException

#Importing requests
import requests

# importing regex
import re<jupyter_output><empty_output><jupyter_text>Scraping flight prices from yatra.com  NEW DELHI TO MUMBAI<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of yatra.com for flights from new delhi to mumbai
url = "https://flight.yatra.com/air-search-ui/dom2/trigger?type=O&viewName=normal&flexi=0&noOfSegments=1&origin=DEL&originCountry=IN&destination=BOM&destinationCountry=IN&flight_depart_date=21%2F01%2F2022&ADT=1&CHD=0&INF=0&class=Economy&source=fresco-home&unqvaldesktop=31443714689"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='i-b text ellipsis']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//p[@title='New Delhi']")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//p[@title='Mumbai']")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='i-b pr']")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//p[@class='bold fs-15 mb-2 pr time']")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text.replace("\n+ 1 day",""))
        
#scraping the duration
duration=driver.find_elements_by_xpath("//p[@class='fs-12 bold du mb-2']")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath(" //div[@class=' font-lightgrey fs-10 tipsy i-b fs-10']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//div[@class='i-b tipsy fare-summary-tooltip fs-18']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text)

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice1", index=False)<jupyter_output><empty_output><jupyter_text>NEW DELHI TO BANGALORE<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of yatra.com for flights from new delhi to bangalore
url = "https://flight.yatra.com/air-search-ui/dom2/trigger?type=O&viewName=normal&flexi=0&noOfSegments=1&origin=DEL&originCountry=IN&destination=BLR&destinationCountry=IN&flight_depart_date=25%2F01%2F2022&ADT=1&CHD=0&INF=0&class=Economy&source=fresco-home&unqvaldesktop=174373601764"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='i-b text ellipsis']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//p[@title='New Delhi']")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//p[@title='Bangalore']")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='i-b pr']")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//p[@class='bold fs-15 mb-2 pr time']")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text.replace("\n+ 1 day",""))
        
#scraping the duration
duration=driver.find_elements_by_xpath("//p[@class='fs-12 bold du mb-2']")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath(" //div[@class=' font-lightgrey fs-10 tipsy i-b fs-10']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//div[@class='i-b tipsy fare-summary-tooltip fs-18']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text)

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice2", index=False)<jupyter_output><empty_output><jupyter_text>KOLKATA TO HYDERABAD<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of yatra.com for flights from kolkata to hyderabad
url = "https://flight.yatra.com/air-search-ui/dom2/trigger?type=O&viewName=normal&flexi=0&noOfSegments=1&origin=CCU&originCountry=IN&destination=HYD&destinationCountry=IN&flight_depart_date=25%2F01%2F2022&ADT=1&CHD=0&INF=0&class=Economy&source=fresco-home&unqvaldesktop=630372204541"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='i-b text ellipsis']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//p[@title='Kolkata']")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//p[@title='Hyderabad']")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='i-b pr']")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//p[@class='bold fs-15 mb-2 pr time']")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text.replace("\n+ 1 day",""))
        
#scraping the duration
duration=driver.find_elements_by_xpath("//p[@class='fs-12 bold du mb-2']")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath(" //div[@class=' font-lightgrey fs-10 tipsy i-b fs-10']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//div[@class='i-b tipsy fare-summary-tooltip fs-18']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text)

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice3", index=False)<jupyter_output><empty_output><jupyter_text>NEW DELHI TO GOA<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of yatra.com for flights from new delhi to goa
url = "https://flight.yatra.com/air-search-ui/dom2/trigger?type=O&viewName=normal&flexi=0&noOfSegments=1&origin=DEL&originCountry=IN&destination=GOI&destinationCountry=IN&flight_depart_date=21%2F01%2F2022&ADT=1&CHD=0&INF=0&class=Economy&source=fresco-home&unqvaldesktop=40220393541"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='i-b text ellipsis']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//p[@title='New Delhi']")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//p[@title='Goa']")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='i-b pr']")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//p[@class='bold fs-15 mb-2 pr time']")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text.replace("\n+ 1 day",""))
        
#scraping the duration
duration=driver.find_elements_by_xpath("//p[@class='fs-12 bold du mb-2']")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath(" //div[@class=' font-lightgrey fs-10 tipsy i-b fs-10']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//div[@class='i-b tipsy fare-summary-tooltip fs-18']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text)

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice4", index=False)<jupyter_output><empty_output><jupyter_text>MUMBAI TO CHENNAI<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of yatra.com for flights from mumbai to chennai
url = "https://flight.yatra.com/air-search-ui/dom2/trigger?type=O&viewName=normal&flexi=0&noOfSegments=1&origin=BOM&originCountry=IN&destination=MAA&destinationCountry=IN&flight_depart_date=21%2F01%2F2022&ADT=1&CHD=0&INF=0&class=Economy&source=fresco-home&unqvaldesktop=278867276410"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='i-b text ellipsis']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//p[@title='Mumbai']")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//p[@title='Chennai']")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='i-b pr']")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//p[@class='bold fs-15 mb-2 pr time']")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text.replace("\n+ 1 day",""))
        
#scraping the duration
duration=driver.find_elements_by_xpath("//p[@class='fs-12 bold du mb-2']")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath(" //div[@class=' font-lightgrey fs-10 tipsy i-b fs-10']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//div[@class='i-b tipsy fare-summary-tooltip fs-18']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text)

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice5", index=False)<jupyter_output><empty_output><jupyter_text>Scraping flight prices from makemytrip.com  DELHI TO BANGALORE<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of makemytrip.com for flights from new delhi to bangalore
url = "https://www.makemytrip.com/flight/search?itinerary=DEL-BLR-22/01/2022&tripType=O&paxType=A-1_C-0_I-0&intl=false&cabinClass=E&ccde=IN&lang=eng"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='boldFont blackText airlineName']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[2]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[2]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[1]/span")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='stop-info flexOne']/p")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//p[@class='flightsLayoverInfo']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//p[@class='blackText fontSize18 blackFont white-space-no-wrap']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹ ",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice6", index=False)<jupyter_output><empty_output><jupyter_text>NEW DELHI TO MUMBAI<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of makemytrip.com for flights from new delhi to mumbai
url = "https://www.makemytrip.com/flight/search?itinerary=DEL-BOM-25/01/2022&tripType=O&paxType=A-1_C-0_I-0&intl=false&cabinClass=E&ccde=IN&lang=eng"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='boldFont blackText airlineName']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[2]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[2]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[1]/span")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='stop-info flexOne']/p")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//p[@class='flightsLayoverInfo']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//p[@class='blackText fontSize18 blackFont white-space-no-wrap']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹ ",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice7", index=False)<jupyter_output><empty_output><jupyter_text>BANGALORE TO AHMEDABAD<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of makemytrip.com for flights from BANGALORE to AHMEDABAD
url = "https://www.makemytrip.com/flight/search?itinerary=BLR-AMD-29/01/2022&tripType=O&paxType=A-1_C-0_I-0&intl=false&cabinClass=E&ccde=IN&lang=eng"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='boldFont blackText airlineName']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[2]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[2]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[1]/span")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='stop-info flexOne']/p")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//p[@class='flightsLayoverInfo']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//p[@class='blackText fontSize18 blackFont white-space-no-wrap']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹ ",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice8", index=False)<jupyter_output><empty_output><jupyter_text>NEW DELHI TO PUNE<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of makemytrip.com for flights from new delhi to pune
url = "https://www.makemytrip.com/flight/search?itinerary=DEL-PNQ-25/01/2022&tripType=O&paxType=A-1_C-0_I-0&intl=false&cabinClass=E&ccde=IN&lang=eng"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='boldFont blackText airlineName']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[2]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[2]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[1]/span")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='stop-info flexOne']/p")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//p[@class='flightsLayoverInfo']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//p[@class='blackText fontSize18 blackFont white-space-no-wrap']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹ ",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice9", index=False)<jupyter_output><empty_output><jupyter_text>BANGALORE TO PUNE<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of makemytrip.com for flights from bangalore to pune
url = "https://www.makemytrip.com/flight/search?itinerary=BLR-PNQ-25/01/2022&tripType=O&paxType=A-1_C-0_I-0&intl=false&cabinClass=E&ccde=IN&lang=eng"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='boldFont blackText airlineName']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[2]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[2]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div [@class='timingOptionOuter']/label/div/div/div[1]/div[1]/p[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='flightTimeSection flexOne timeInfoRight']/div[1]/p[1]/span")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='stop-info flexOne']/p")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//p[@class='flightsLayoverInfo']")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//p[@class='blackText fontSize18 blackFont white-space-no-wrap']")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹ ",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice10", index=False)<jupyter_output><empty_output><jupyter_text>Scraping flight prices from tripodeal.com  BANGALORE TO GOA<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of tripodeal.com for flights from bangalore to goa
url = "https://www.tripodeal.com/results?tid=61ea1aff30f0d80b424280b9"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice11", index=False)<jupyter_output><empty_output><jupyter_text>KOLKATA TO PUNE<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of tripodeal.com for flights from kolkata to pune
url = "https://www.tripodeal.com/results?tid=61ea1d0159474c70496d099b"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice12", index=False)<jupyter_output><empty_output><jupyter_text>MUMBAI TO COCHIN(KOCHI)<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of tripodeal.com for flights from mumbai to cochin(kochi)
url = "https://www.tripodeal.com/results?tid=61ea1eefe0c2a86d2a3f5c1a"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice13", index=False)<jupyter_output><empty_output><jupyter_text>MUMBAI TO NEW DELHI<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of tripodeal.com for flights from mumbai to new delhi
url = "https://www.tripodeal.com/results?tid=61ea2156f7771b23c74b9748"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice14", index=False)<jupyter_output><empty_output><jupyter_text>HYDERABAD TO MUMBAI<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of tripodeal.com for flights from hyderabad to mumbai
url = "https://www.tripodeal.com/results?tid=61ea22df0e9e9b361b58684b"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice15", index=False)<jupyter_output><empty_output><jupyter_text>COCHIN(KOCHI) TO BANGALORE<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of tripodeal.com for flights from cochin(kochi) to bangalore
url = "https://www.tripodeal.com/results?tid=61ea24d623eed84e5c6fa830"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice16", index=False)<jupyter_output><empty_output><jupyter_text>Scraping flight prices from vimaansafar.com  AHMEDABAD TO MUMBAI<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of vimaansafar.com for flights from ahmedabad to mumbai
url = "https://www.vimaansafar.com/results?tid=61ea285374934e639069bba7"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice17", index=False)<jupyter_output><empty_output><jupyter_text>AHMEDABAD TO NEW DELHI<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of vimaansafar.com for flights from ahmedabad to new delhi
url = "https://www.vimaansafar.com/results?tid=61ea2c7f893d2c045c3945df"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice18", index=False)<jupyter_output><empty_output><jupyter_text>CHENNAI TO BANGALORE<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of vimaansafar.com for flights from chennai to bangalore
url = "https://www.vimaansafar.com/results?tid=61ea2e9ddbe51c72794c9536"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice19", index=False)<jupyter_output><empty_output><jupyter_text>NEW DELHI TO CHANDIGARH<jupyter_code># Activating the chrome browser
driver=webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
# Opening page of vimaansafar.com for flights from new delhi to chandigarh
url = "https://www.vimaansafar.com/results?tid=61ea306ef6ed1b780e0a7f19"
driver.get(url)
# creating empty lists for scraping data
airline_name=[]
source=[]
destination=[]
departure_time=[]
arrival_time=[]
travel_duration=[]
total_stops=[]
price=[]


#scraping the airlines name
name=driver.find_elements_by_xpath("//span[@class='text-muted d-none d-lg-inline ']")
for i in name:
    if i.text is None :
        airline_name.append("--") 
    else:
        airline_name.append(i.text)
        
#scraping the source
source_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[3]")
for i in source_name:
    if i.text is None :
        source.append("--") 
    else:
        source.append(i.text)
        
#scraping the destination
dest_name=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span[3]")
for i in dest_name:
    if i.text is None :
        destination.append("--") 
    else:
        destination.append(i.text)
        
#scraping the departure time
time=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[2]/div/div/span[2]/span[1]")
for i in time:
    if i.text is None :
        departure_time.append("--") 
    else:
        departure_time.append(i.text)
        
#scraping the arrival time
arrtime=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[4]/div/div/span/span[1]")
for i in arrtime:
    if i.text is None :
        arrival_time.append("--") 
    else:
        arrival_time.append(i.text)
        
#scraping the duration
duration=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[1]")
for i in duration:
    if i.text is None :
        travel_duration.append("--") 
    else:
        travel_duration.append(i.text)
        
#scraping total stops
stops=driver.find_elements_by_xpath("//div[@class='row keel-mom no-gutters']/div[3]/div/div/div[3]")
for i in stops:
    if i.text is None :
        total_stops.append("--") 
    else:
        total_stops.append(i.text)
        
#scraping the price
prc=driver.find_elements_by_xpath("//h5[@class='mb-2 font-weight-bold']/span[1]")
for i in prc:
    if i.text is None :
        price.append("--") 
    else:
        price.append(i.text.replace("₹",""))

# creating the dataframe from the scraped data
df=pd.DataFrame({"Airline Name":airline_name,"Source":source,"Destination":destination,"Departure Time":departure_time,"Arrival Time":arrival_time,"Duration":travel_duration,"Total Stops":total_stops,"Price":price})
df      
df.to_csv("FlightPrice20", index=False)
#loading all the files

df1 = pd.read_csv("FlightPrice1")
df2 = pd.read_csv("FlightPrice2")
df3 = pd.read_csv("FlightPrice3")
df4 = pd.read_csv("FlightPrice4")
df5 = pd.read_csv("FlightPrice5")
df6 = pd.read_csv("FlightPrice6")
df7 = pd.read_csv("FlightPrice7")
df8 = pd.read_csv("FlightPrice8")
df9 = pd.read_csv("FlightPrice9")
df10 = pd.read_csv("FlightPrice10")
df11 = pd.read_csv("FlightPrice11")
df12 = pd.read_csv("FlightPrice12")
df13 = pd.read_csv("FlightPrice13")
df14 = pd.read_csv("FlightPrice14")
df15 = pd.read_csv("FlightPrice15")
df16 = pd.read_csv("FlightPrice16")
df17 = pd.read_csv("FlightPrice17")
df18 = pd.read_csv("FlightPrice18")
df19 = pd.read_csv("FlightPrice19")
df20 = pd.read_csv("FlightPrice20")
#concatinating all the files
Price_Prediction = pd.concat([df1,df2,df3,df4,df5,df6,df7,df8,df9,df10,df11,df12,df13,df14,df15,df16,df17,df18,df19,df20], ignore_index= True)
Price_Prediction
Price_Prediction.to_csv("Flight_Price_Prediction_Scrapped_Data_File.csv")
Price_Prediction.to_excel("FlightPrice_Prediction.xlsx")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14525120732017283, 'fraction_numerical': 0.01281030246547488, 'mean_word_length': 3.883409184940008, 'pattern_counts': {'":': 160, '<': 85, '<?xml version=': 0, '>': 85, 'https://': 20, 'lorem ipsum': 0, 'www.': 15, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '21', 'dir': 'jupyter-structured-clean-dedup', 'id': '291819', 'license': 'MIT', 'n_tokens_mistral': 21891, 'n_tokens_neox': 21158, 'n_words': 3914, 'path': 'Flight-Price-Prediction_WebScrapping.ipynb', 'repo_name': 'asifansar120/Flight-Price-Prediction-', 'size': '59015'}