├── .SmartGitAuto ├── requirements.txt ├── README.md └── flight.py /.SmartGitAuto: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.9.3 2 | bs4==0.0.1 3 | selenium==3.141.0 4 | soupsieve==2.0.1 5 | urllib3==1.25.10 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AutomationFlight 2 | 3 | This app is made specifically for https://www.makemytrip.com/ 4 | 5 | Requirements: 6 | 1. Chrome driver - (Can be installed from : https://chromedriver.chromium.org/) PS: CHECK FOR THE VERSION AND DOWNLOAD THE SUITABLE ONE 7 | 2. install all packages from requiremnts.txt 8 | 9 | Give the proper location for Chrome Driver installed path at line 5 10 | - driver = webdriver.Chrome(executable_path=r"YOUR PATH TO CHROMEDRIVER") 11 | 12 | CITY given : Trivandrum. 13 | DATE given : 16th October 2020 14 | 15 | The app will generate 5 flight lists based on descending order of price. 16 | -------------------------------------------------------------------------------- /flight.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from bs4 import BeautifulSoup 3 | from time import sleep 4 | 5 | driver = webdriver.Chrome(executable_path=r"C:\chromedriver\chromedriver.exe") #Give the path to chromedriver 6 | driver.get("https://www.makemytrip.com/") 7 | 8 | n = input("Enter Confirmation ") #Type anything after complete loading of the website. 9 | 10 | path = '//*[@id="root"]/div/div[2]/div/div/div[2]' 11 | driver.find_element_by_xpath(path).click() #opening destination list 12 | 13 | sleep(5) 14 | 15 | path2 = '//*[@id="root"]/div/div[2]/div/div/div[2]/div[1]/div[2]/div[1]/div/div/div/input' 16 | driver.find_element_by_xpath(path2).send_keys('TRV') #Trivandrum, India 17 | 18 | sleep(5) 19 | 20 | path3 = '//*[@id="react-autowhatever-1"]/div[1]' 21 | driver.find_element_by_xpath(path3).click() #Selection City 22 | 23 | sleep(5) 24 | 25 | path4 = '//*[@id="root"]/div/div[2]/div/div/div[2]/div[1]/div[3]/div[1]/div/div/div/div[2]/div/div[2]/div[1]/div[3]/div[3]/div[6]' 26 | driver.find_element_by_xpath(path4).click() #Date Selection 27 | 28 | sleep(5) 29 | 30 | path5 = '//*[@id="root"]/div/div[2]/div/div/div[2]/p/a' 31 | driver.find_element_by_xpath(path5).click() #Submit Button 32 | 33 | sleep(5) 34 | 35 | path6 = '//*[@id="sorting-togglers"]/div[5]/span' 36 | driver.find_element_by_xpath(path6).click() #Select Price Descending order 37 | 38 | sleep(10) 39 | 40 | flight = [] 41 | 42 | content = driver.page_source 43 | soup = BeautifulSoup(content, features="html.parser") 44 | 45 | name = [] 46 | DeptTime = [] 47 | ArrTime = [] 48 | cost = [] 49 | 50 | count = 0 51 | 52 | if soup.findAll('div', attrs={'class': 'one-way'}): 53 | for a in soup.findAll('span', attrs={'class': 'airways-name'}): 54 | count = count + 1 55 | name.append(a.get_text()) 56 | if count == 5: 57 | break 58 | count = 0 59 | for a in soup.findAll('div', attrs={'class': 'dept-time'}): 60 | count = count + 1 61 | DeptTime.append(a.get_text()) 62 | if count == 5: 63 | break 64 | count = 0 65 | for a in soup.findAll('p', attrs={'class': 'reaching-time append_bottom3'}): 66 | count = count + 1 67 | ArrTime.append(a.get_text()) 68 | if count == 5: 69 | break 70 | count = 0 71 | for a in soup.findAll('span', attrs={'class': 'actual-price'}): 72 | count = count + 1 73 | cost.append(a.get_text()) 74 | if count == 5: 75 | break 76 | 77 | print("NEXT") 78 | else: 79 | print("NOPE") 80 | 81 | for i in range(5): 82 | print("Flight no : "+str(i+1)) 83 | print("Flight Name : "+name[i]) 84 | print("Flight Departure Time : "+DeptTime[i]) 85 | print("Flight Arrival Time : "+ArrTime[i]) 86 | print("Flight Cost : "+cost[i]) 87 | print() --------------------------------------------------------------------------------