diff --git a/examples/cdp_mode/raw_nordstrom.py b/examples/cdp_mode/raw_nordstrom.py new file mode 100644 index 00000000000..fdb3ab11432 --- /dev/null +++ b/examples/cdp_mode/raw_nordstrom.py @@ -0,0 +1,26 @@ +from seleniumbase import SB + +with SB(uc=True, test=True, locale_code="en") as sb: + url = "https://www.nordstrom.com/" + sb.activate_cdp_mode(url) + sb.sleep(2.2) + sb.cdp.click("input#keyword-search-input") + sb.sleep(0.8) + search = "cocktail dresses for women teal" + sb.cdp.press_keys("input#keyword-search-input", search + "\n") + sb.sleep(2.2) + for i in range(16): + sb.cdp.scroll_down(16) + sb.sleep(0.16) + print('*** Nordstrom Search for "%s":' % search) + unique_item_text = [] + items = sb.cdp.find_elements("article") + for item in items: + description = item.querySelector("article h3") + if description and description.text not in unique_item_text: + unique_item_text.append(description.text) + price_text = "" + price = item.querySelector('div div span[aria-hidden="true"]') + if price: + price_text = price.text + print("* %s (%s)" % (description.text, price_text)) diff --git a/examples/cdp_mode/raw_southwest.py b/examples/cdp_mode/raw_southwest.py new file mode 100644 index 00000000000..0c3f7c9d57a --- /dev/null +++ b/examples/cdp_mode/raw_southwest.py @@ -0,0 +1,33 @@ +from seleniumbase import SB + +with SB(uc=True, test=True, locale_code="en") as sb: + url = "https://www.southwest.com/air/booking/" + sb.activate_cdp_mode(url) + sb.sleep(2.8) + origin = "DEN" + destination = "PHX" + sb.cdp.gui_click_element("input#originationAirportCode") + sb.sleep(0.2) + sb.uc_gui_press_keys(origin + "\n") + sb.sleep(0.5) + sb.cdp.gui_click_element("h1.heading") + sb.sleep(0.5) + sb.cdp.gui_click_element("input#destinationAirportCode") + sb.sleep(0.2) + sb.uc_gui_press_keys(destination + "\n") + sb.sleep(0.5) + sb.cdp.gui_click_element("h1.heading") + sb.sleep(0.5) + sb.cdp.click('form button[aria-label*="Search"]') + sb.sleep(4) + day = sb.cdp.get_text('[aria-current="true"] span[class*="cal"]') + print("**** Flights from %s to %s ****" % (origin, destination)) + flights = sb.find_elements("li.air-booking-select-detail") + for flight in flights: + info = flight.text + departs = info.split("Departs")[-1].split("M")[0].strip() + "M" + arrives = info.split("Arrives")[-1].split("M")[0].strip() + "M" + stops = flight.query_selector(".flight-stops-badge").text + duration = flight.query_selector('[class*="flight-duration"]').text + price = flight.query_selector('span.currency span[aria-hidden]').text + print(f"* {day}, {departs} -> {arrives} ({stops}: {duration}) {price}")