Update flight search examples
This commit is contained in:
parent
6e4b5f52a8
commit
19a8e50400
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue