Update flight search examples
This commit is contained in:
parent
413a762e6b
commit
d06663fadd
|
@ -4,27 +4,26 @@ with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
|
|||
url = "https://www.southwest.com/air/booking/"
|
||||
sb.activate_cdp_mode(url)
|
||||
sb.sleep(2.8)
|
||||
cookie_pop_up = '[class*="PopOverContainer"] span'
|
||||
if sb.cdp.is_element_visible(cookie_pop_up):
|
||||
sb.cdp.mouse_click(cookie_pop_up)
|
||||
origin = "BOS"
|
||||
destination = "MDW"
|
||||
sb.cdp.click("button#onetrust-accept-btn-handler")
|
||||
sb.sleep(0.5)
|
||||
sb.cdp.gui_click_element("input#originationAirportCode")
|
||||
sb.sleep(0.5)
|
||||
sb.uc_gui_press_keys(" " + "\n")
|
||||
sb.sleep(0.5)
|
||||
sb.cdp.gui_click_element("input#originationAirportCode")
|
||||
sb.sleep(0.5)
|
||||
sb.sleep(0.4)
|
||||
sb.uc_gui_press_keys(origin + "\n")
|
||||
sb.sleep(0.5)
|
||||
sb.sleep(0.4)
|
||||
sb.cdp.gui_click_element("h1.heading")
|
||||
sb.sleep(0.5)
|
||||
sb.sleep(0.3)
|
||||
sb.cdp.gui_click_element("input#destinationAirportCode")
|
||||
sb.sleep(0.5)
|
||||
sb.sleep(0.4)
|
||||
sb.uc_gui_press_keys(destination + "\n")
|
||||
sb.sleep(0.5)
|
||||
sb.sleep(0.4)
|
||||
sb.cdp.gui_click_element("h1.heading")
|
||||
sb.sleep(0.5)
|
||||
sb.sleep(0.3)
|
||||
sb.cdp.click('form button[aria-label*="Search"]')
|
||||
sb.sleep(4)
|
||||
day = sb.cdp.get_text('[aria-current="true"] span[class*="cal"]')
|
||||
|
|
|
@ -9,13 +9,13 @@ with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
|
|||
destination_input = 'input[placeholder="Destination"]'
|
||||
destination = "Orlando, FL"
|
||||
sb.cdp.gui_click_element(origin_input)
|
||||
sb.sleep(1.2)
|
||||
sb.sleep(0.5)
|
||||
sb.cdp.type(origin_input, origin)
|
||||
sb.sleep(1.2)
|
||||
sb.cdp.click('strong:contains("%s")' % origin)
|
||||
sb.sleep(1.2)
|
||||
sb.cdp.gui_click_element(destination_input)
|
||||
sb.sleep(1.2)
|
||||
sb.sleep(0.5)
|
||||
sb.cdp.type(destination_input, destination)
|
||||
sb.sleep(1.2)
|
||||
sb.cdp.click('strong:contains("%s")' % destination)
|
||||
|
@ -28,5 +28,23 @@ with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
|
|||
if not flights:
|
||||
print("* No flights found!")
|
||||
for flight in flights:
|
||||
print("* " + flight.text.split(" Destination")[0])
|
||||
flight_info = flight.text.split(" Destination")[0]
|
||||
part_1 = flight_info.split(" Departing at")[0]
|
||||
part_2 = flight_info.split("Arriving at ")[-1]
|
||||
part_2 = part_2.split(" Duration")[0]
|
||||
part_3 = flight.text.split(" Destination")[-1].split(" Aircraft")[0]
|
||||
parts = "%s - %s %s" % (part_1, part_2, part_3)
|
||||
print("* " + parts)
|
||||
for category in ["ECO-BASIC", "ECONOMY"]:
|
||||
prices = sb.find_elements('[aria-describedby="%s"]' % category)
|
||||
full_prices = []
|
||||
for item in prices:
|
||||
item_text = item.text
|
||||
if "Not available" not in item.text:
|
||||
full_prices.append("$%s" % item.text.split("$")[-1])
|
||||
else:
|
||||
full_prices.append("N/A")
|
||||
print("**** %s Prices:" % category)
|
||||
print(full_prices)
|
||||
sb.cdp.scroll_down(50)
|
||||
sb.sleep(1.5)
|
||||
|
|
Loading…
Reference in New Issue