File tree 3 files changed +19
-5
lines changed
3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change
1
+ import datetime
1
2
import re
2
3
from seleniumbase import SB
3
4
4
5
with SB (uc = True , test = True , locale = "en" ) as sb :
5
6
url = "www.elal.com/flight-deals/en-us/flights-from-boston-to-tel-aviv"
6
7
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 )
8
21
sb .cdp .click ('button[data-att="search"]' )
9
22
sb .sleep (5 )
10
23
sb .cdp .click_if_visible ("#onetrust-close-btn-container button" )
Original file line number Diff line number Diff line change 7
7
cookie_pop_up = '[class*="PopOverContainer"] span'
8
8
if sb .cdp .is_element_visible (cookie_pop_up ):
9
9
sb .cdp .mouse_click (cookie_pop_up )
10
- origin = "DEN "
11
- destination = "PHX "
10
+ origin = "BOS "
11
+ destination = "MDW "
12
12
sb .cdp .gui_click_element ("input#originationAirportCode" )
13
13
sb .sleep (0.5 )
14
14
sb .uc_gui_press_keys (" " + "\n " )
Original file line number Diff line number Diff line change 5
5
sb .activate_cdp_mode (url )
6
6
sb .sleep (2.5 )
7
7
origin_input = 'input[placeholder="Origin"]'
8
- origin = "Boston, MA "
8
+ origin = "New York, NY "
9
9
destination_input = 'input[placeholder="Destination"]'
10
- destination = "San Diego, CA "
10
+ destination = "Orlando, FL "
11
11
sb .cdp .gui_click_element (origin_input )
12
12
sb .sleep (1.2 )
13
13
sb .cdp .type (origin_input , origin )
24
24
sb .sleep (6 )
25
25
flights = sb .find_elements ('div[class*="CardContainer__block"]' )
26
26
print ("**** Flights from %s to %s ****" % (origin , destination ))
27
+ print (" (" + sb .get_text ("h2.atm-c-heading" ) + ")" )
27
28
if not flights :
28
29
print ("* No flights found!" )
29
30
for flight in flights :
You can’t perform that action at this time.
0 commit comments