File tree Expand file tree Collapse file tree 2 files changed +29
-12
lines changed Expand file tree Collapse file tree 2 files changed +29
-12
lines changed Original file line number Diff line number Diff line change 44 url = "https://www.southwest.com/air/booking/"
55 sb .activate_cdp_mode (url )
66 sb .sleep (2.8 )
7- cookie_pop_up = '[class*="PopOverContainer"] span'
8- if sb .cdp .is_element_visible (cookie_pop_up ):
9- sb .cdp .mouse_click (cookie_pop_up )
107 origin = "BOS"
118 destination = "MDW"
9+ sb .cdp .click ("button#onetrust-accept-btn-handler" )
10+ sb .sleep (0.5 )
1211 sb .cdp .gui_click_element ("input#originationAirportCode" )
1312 sb .sleep (0.5 )
1413 sb .uc_gui_press_keys (" " + "\n " )
1514 sb .sleep (0.5 )
1615 sb .cdp .gui_click_element ("input#originationAirportCode" )
17- sb .sleep (0.5 )
16+ sb .sleep (0.4 )
1817 sb .uc_gui_press_keys (origin + "\n " )
19- sb .sleep (0.5 )
18+ sb .sleep (0.4 )
2019 sb .cdp .gui_click_element ("h1.heading" )
21- sb .sleep (0.5 )
20+ sb .sleep (0.3 )
2221 sb .cdp .gui_click_element ("input#destinationAirportCode" )
23- sb .sleep (0.5 )
22+ sb .sleep (0.4 )
2423 sb .uc_gui_press_keys (destination + "\n " )
25- sb .sleep (0.5 )
24+ sb .sleep (0.4 )
2625 sb .cdp .gui_click_element ("h1.heading" )
27- sb .sleep (0.5 )
26+ sb .sleep (0.3 )
2827 sb .cdp .click ('form button[aria-label*="Search"]' )
2928 sb .sleep (4 )
3029 day = sb .cdp .get_text ('[aria-current="true"] span[class*="cal"]' )
Original file line number Diff line number Diff line change 99 destination_input = 'input[placeholder="Destination"]'
1010 destination = "Orlando, FL"
1111 sb .cdp .gui_click_element (origin_input )
12- sb .sleep (1.2 )
12+ sb .sleep (0.5 )
1313 sb .cdp .type (origin_input , origin )
1414 sb .sleep (1.2 )
1515 sb .cdp .click ('strong:contains("%s")' % origin )
1616 sb .sleep (1.2 )
1717 sb .cdp .gui_click_element (destination_input )
18- sb .sleep (1.2 )
18+ sb .sleep (0.5 )
1919 sb .cdp .type (destination_input , destination )
2020 sb .sleep (1.2 )
2121 sb .cdp .click ('strong:contains("%s")' % destination )
2828 if not flights :
2929 print ("* No flights found!" )
3030 for flight in flights :
31- print ("* " + flight .text .split (" Destination" )[0 ])
31+ flight_info = flight .text .split (" Destination" )[0 ]
32+ part_1 = flight_info .split (" Departing at" )[0 ]
33+ part_2 = flight_info .split ("Arriving at " )[- 1 ]
34+ part_2 = part_2 .split (" Duration" )[0 ]
35+ part_3 = flight .text .split (" Destination" )[- 1 ].split (" Aircraft" )[0 ]
36+ parts = "%s - %s %s" % (part_1 , part_2 , part_3 )
37+ print ("* " + parts )
38+ for category in ["ECO-BASIC" , "ECONOMY" ]:
39+ prices = sb .find_elements ('[aria-describedby="%s"]' % category )
40+ full_prices = []
41+ for item in prices :
42+ item_text = item .text
43+ if "Not available" not in item .text :
44+ full_prices .append ("$%s" % item .text .split ("$" )[- 1 ])
45+ else :
46+ full_prices .append ("N/A" )
47+ print ("**** %s Prices:" % category )
48+ print (full_prices )
49+ sb .cdp .scroll_down (50 )
3250 sb .sleep (1.5 )
You can’t perform that action at this time.
0 commit comments