File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ from seleniumbase import SB
2+
3+ with SB (uc = True , test = True , locale_code = "en" ) as sb :
4+ url = "https://www.nordstrom.com/"
5+ sb .activate_cdp_mode (url )
6+ sb .sleep (2.2 )
7+ sb .cdp .click ("input#keyword-search-input" )
8+ sb .sleep (0.8 )
9+ search = "cocktail dresses for women teal"
10+ sb .cdp .press_keys ("input#keyword-search-input" , search + "\n " )
11+ sb .sleep (2.2 )
12+ for i in range (16 ):
13+ sb .cdp .scroll_down (16 )
14+ sb .sleep (0.16 )
15+ print ('*** Nordstrom Search for "%s":' % search )
16+ unique_item_text = []
17+ items = sb .cdp .find_elements ("article" )
18+ for item in items :
19+ description = item .querySelector ("article h3" )
20+ if description and description .text not in unique_item_text :
21+ unique_item_text .append (description .text )
22+ price_text = ""
23+ price = item .querySelector ('div div span[aria-hidden="true"]' )
24+ if price :
25+ price_text = price .text
26+ print ("* %s (%s)" % (description .text , price_text ))
Original file line number Diff line number Diff line change 1+ from seleniumbase import SB
2+
3+ with SB (uc = True , test = True , locale_code = "en" ) as sb :
4+ url = "https://www.southwest.com/air/booking/"
5+ sb .activate_cdp_mode (url )
6+ sb .sleep (2.8 )
7+ origin = "DEN"
8+ destination = "PHX"
9+ sb .cdp .gui_click_element ("input#originationAirportCode" )
10+ sb .sleep (0.2 )
11+ sb .uc_gui_press_keys (origin + "\n " )
12+ sb .sleep (0.5 )
13+ sb .cdp .gui_click_element ("h1.heading" )
14+ sb .sleep (0.5 )
15+ sb .cdp .gui_click_element ("input#destinationAirportCode" )
16+ sb .sleep (0.2 )
17+ sb .uc_gui_press_keys (destination + "\n " )
18+ sb .sleep (0.5 )
19+ sb .cdp .gui_click_element ("h1.heading" )
20+ sb .sleep (0.5 )
21+ sb .cdp .click ('form button[aria-label*="Search"]' )
22+ sb .sleep (4 )
23+ day = sb .cdp .get_text ('[aria-current="true"] span[class*="cal"]' )
24+ print ("**** Flights from %s to %s ****" % (origin , destination ))
25+ flights = sb .find_elements ("li.air-booking-select-detail" )
26+ for flight in flights :
27+ info = flight .text
28+ departs = info .split ("Departs" )[- 1 ].split ("M" )[0 ].strip () + "M"
29+ arrives = info .split ("Arrives" )[- 1 ].split ("M" )[0 ].strip () + "M"
30+ stops = flight .query_selector (".flight-stops-badge" ).text
31+ duration = flight .query_selector ('[class*="flight-duration"]' ).text
32+ price = flight .query_selector ('span.currency span[aria-hidden]' ).text
33+ print (f"* { day } , { departs } -> { arrives } ({ stops } : { duration } ) { price } " )
You can’t perform that action at this time.
0 commit comments