<jupyter_start><jupyter_text>Travel for Cheap Search and compare flight fares for various destinations on SkyScanner<jupyter_code>from selenium import webdriver
from time import sleep
ch_driver = webdriver.Chrome('C:/Users/beave/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Python 3.7/chromedriver.exe')
#To access US website in Korea,
url = 'https://www.skyscanner.com/?market=US&locale=en-US&_ga=2.3699184.1771001494.1546424454-235103862.1535629143'

ch_driver.get(url)
origin_input = ch_driver.find_element_by_id('origin-fsc-search')
origin_input.click()
origin = input("From: ")
origin_input.send_keys(origin)
dest_input = ch_driver.find_element_by_id('destination-fsc-search')
dest_input.click()
destination = input("To: ")
dest_input.send_keys(destination)
#Select Depart Date

depart_button = ch_driver.find_element_by_id('depart-fsc-datepicker-button')
depart_button.click()

depart_input = input("Select Depart Date Month/Date: ")
depart = depart_input.split("/")
depart_month = int(depart[0])
depart_date = depart[1]

#select month
depart_months = ch_driver.find_element_by_id('depart-calendar__bpk_calendar_nav_select')
depart_months.click()
depart_months.find_elements_by_tag_name('option')[depart_month].click()

#select date

depart_dates = ch_driver.find_elements_by_class_name('bpk-calendar-date-1Mg7I')

for item in depart_dates:
    depart_span = item.find_element_by_tag_name('span')
    if depart_span.text == depart_date:
        depart_span.click()
        break
#Select Return Date

return_button = ch_driver.find_element_by_id('return-fsc-datepicker-button')
return_button.click()

return_input = input("Select Return Date Month/Date: ")
return_list = return_input.split("/")
return_month = int(return_list[0]) - 1
return_date = return_list[1]

#select month
return_months = ch_driver.find_element_by_id('return-calendar__bpk_calendar_nav_select')
return_months.click()
return_months.find_elements_by_tag_name('option')[return_month].click()

return_dates = ch_driver.find_elements_by_class_name('bpk-calendar-date-1Mg7I')

for item in return_dates:
    return_span = item.find_element_by_tag_name('span')
    if return_span.text == return_date:
        return_span.click()
        break
#non-stop flights only
direct_only = ch_driver.find_element_by_name('directOnly')
direct_only.click()
#search flights click()
search_flights = ch_driver.find_element_by_xpath('//*[@id="flights-search-controls-root"]/div/div/form/div[3]/button')
search_flights.click()
#Scrape 10 cheapest result
ch_driver.implicitly_wait(60)

itenary = ch_driver.find_elements_by_xpath('//*[@id="day-section"]/div/div[3]/div[4]/div/ul/li/div/article/div/div[1]/div/div')
#get airline name

airlines = itenary[2].ch_driver.find_elements_by_class_name('airline-name')
depart_airline = airlines[0].text
return_airline = airlines[1].text

print(depart_airline, return_airline)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12284927735719202, 'fraction_numerical': 0.023743977976600137, 'mean_word_length': 7.052631578947368, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '217359', 'license': 'MIT', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1025, 'n_words': 150, 'path': 'python/web-scraping/Web-Scraping_SkyScanner.ipynb', 'repo_name': 'mindudekim/TIL', 'size': '2906'}