File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1+ import datetime
12import re
23from seleniumbase import SB
34
45with SB (uc = True , test = True , locale = "en" ) as sb :
56 url = "www.elal.com/flight-deals/en-us/flights-from-boston-to-tel-aviv"
67 sb .activate_cdp_mode (url )
7- sb .sleep (2 )
8+ sb .sleep (3 )
9+ sb .cdp .click ('label:contains("Departure date")' )
10+ sb .sleep (1 )
11+ today = datetime .date .today ()
12+ days_ahead = (4 - today .weekday () + 7 ) % 7
13+ next_friday = today + datetime .timedelta (days = days_ahead )
14+ formatted_date = next_friday .strftime ("%m/%d/%Y" )
15+ sb .cdp .gui_click_element ('input[aria-describedby*="date-input"]' )
16+ sb .sleep (1 )
17+ sb .cdp .gui_press_keys ("\b " * 10 + formatted_date + "\n " )
18+ sb .sleep (1 )
19+ sb .cdp .click ('button[data-att="done"]' )
20+ sb .sleep (1 )
821 sb .cdp .click ('button[data-att="search"]' )
922 sb .sleep (5 )
1023 sb .cdp .click_if_visible ("#onetrust-close-btn-container button" )
Original file line number Diff line number Diff line change 77 cookie_pop_up = '[class*="PopOverContainer"] span'
88 if sb .cdp .is_element_visible (cookie_pop_up ):
99 sb .cdp .mouse_click (cookie_pop_up )
10- origin = "DEN "
11- destination = "PHX "
10+ origin = "BOS "
11+ destination = "MDW "
1212 sb .cdp .gui_click_element ("input#originationAirportCode" )
1313 sb .sleep (0.5 )
1414 sb .uc_gui_press_keys (" " + "\n " )
Original file line number Diff line number Diff line change 55 sb .activate_cdp_mode (url )
66 sb .sleep (2.5 )
77 origin_input = 'input[placeholder="Origin"]'
8- origin = "Boston, MA "
8+ origin = "New York, NY "
99 destination_input = 'input[placeholder="Destination"]'
10- destination = "San Diego, CA "
10+ destination = "Orlando, FL "
1111 sb .cdp .gui_click_element (origin_input )
1212 sb .sleep (1.2 )
1313 sb .cdp .type (origin_input , origin )
2424 sb .sleep (6 )
2525 flights = sb .find_elements ('div[class*="CardContainer__block"]' )
2626 print ("**** Flights from %s to %s ****" % (origin , destination ))
27+ print (" (" + sb .get_text ("h2.atm-c-heading" ) + ")" )
2728 if not flights :
2829 print ("* No flights found!" )
2930 for flight in flights :
You can’t perform that action at this time.
0 commit comments