-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}") |