From 19a8e504005d2d4b4fda5a94e71676a4ba2d10d8 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Tue, 25 Mar 2025 16:07:56 -0400 Subject: [PATCH] Update flight search examples --- examples/cdp_mode/raw_elal.py | 15 ++++++++++++++- examples/cdp_mode/raw_southwest.py | 4 ++-- examples/cdp_mode/raw_united.py | 5 +++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/cdp_mode/raw_elal.py b/examples/cdp_mode/raw_elal.py index 137b9a94..8491fb7d 100644 --- a/examples/cdp_mode/raw_elal.py +++ b/examples/cdp_mode/raw_elal.py @@ -1,10 +1,23 @@ +import datetime import re from seleniumbase import SB with SB(uc=True, test=True, locale="en") as sb: url = "www.elal.com/flight-deals/en-us/flights-from-boston-to-tel-aviv" sb.activate_cdp_mode(url) - sb.sleep(2) + sb.sleep(3) + sb.cdp.click('label:contains("Departure date")') + sb.sleep(1) + today = datetime.date.today() + days_ahead = (4 - today.weekday() + 7) % 7 + next_friday = today + datetime.timedelta(days=days_ahead) + formatted_date = next_friday.strftime("%m/%d/%Y") + sb.cdp.gui_click_element('input[aria-describedby*="date-input"]') + sb.sleep(1) + sb.cdp.gui_press_keys("\b" * 10 + formatted_date + "\n") + sb.sleep(1) + sb.cdp.click('button[data-att="done"]') + sb.sleep(1) sb.cdp.click('button[data-att="search"]') sb.sleep(5) sb.cdp.click_if_visible("#onetrust-close-btn-container button") diff --git a/examples/cdp_mode/raw_southwest.py b/examples/cdp_mode/raw_southwest.py index 1f9fcc0a..e7f0df24 100644 --- a/examples/cdp_mode/raw_southwest.py +++ b/examples/cdp_mode/raw_southwest.py @@ -7,8 +7,8 @@ with SB(uc=True, test=True, locale="en", ad_block=True) as sb: cookie_pop_up = '[class*="PopOverContainer"] span' if sb.cdp.is_element_visible(cookie_pop_up): sb.cdp.mouse_click(cookie_pop_up) - origin = "DEN" - destination = "PHX" + origin = "BOS" + destination = "MDW" sb.cdp.gui_click_element("input#originationAirportCode") sb.sleep(0.5) sb.uc_gui_press_keys(" " + "\n") diff --git a/examples/cdp_mode/raw_united.py b/examples/cdp_mode/raw_united.py index cf39c8b1..a7e01f81 100644 --- a/examples/cdp_mode/raw_united.py +++ b/examples/cdp_mode/raw_united.py @@ -5,9 +5,9 @@ with SB(uc=True, test=True, locale="en", ad_block=True) as sb: sb.activate_cdp_mode(url) sb.sleep(2.5) origin_input = 'input[placeholder="Origin"]' - origin = "Boston, MA" + origin = "New York, NY" destination_input = 'input[placeholder="Destination"]' - destination = "San Diego, CA" + destination = "Orlando, FL" sb.cdp.gui_click_element(origin_input) sb.sleep(1.2) sb.cdp.type(origin_input, origin) @@ -24,6 +24,7 @@ with SB(uc=True, test=True, locale="en", ad_block=True) as sb: sb.sleep(6) flights = sb.find_elements('div[class*="CardContainer__block"]') print("**** Flights from %s to %s ****" % (origin, destination)) + print(" (" + sb.get_text("h2.atm-c-heading") + ")") if not flights: print("* No flights found!") for flight in flights: