Skip to content

Commit

Permalink
Set driver option "mobile=True" (#321)
Browse files Browse the repository at this point in the history
Go to check-in page directly instead of homepage.

Helps avoid 403/429s more.
  • Loading branch information
dmytrokoren authored Nov 15, 2024
1 parent f008ace commit e28f4a6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .reservation_monitor import AccountMonitor

BASE_URL = "https://mobile.southwest.com"
CHECKIN_URL = BASE_URL + "/air/check-in/"
LOGIN_URL = BASE_URL + "/api/security/v4/security/token"
TRIPS_URL = BASE_URL + "/api/mobile-misc/v1/mobile-misc/page/upcoming-trips"
HEADERS_URL = BASE_URL + "/api/mobile-air-booking/v1/mobile-air-booking/feature/shopping-details"
Expand Down Expand Up @@ -148,15 +149,15 @@ def _get_driver(self) -> Driver:
uc_cdp_events=True,
undetectable=True,
incognito=True,
mobile=True,
)
logger.debug("Using browser version: %s", driver.caps["browserVersion"])

driver.add_cdp_listener("Network.requestWillBeSent", self._headers_listener)

logger.debug("Loading Southwest home page (this may take a moment)")
driver.open(BASE_URL)
logger.debug("Loading Southwest check-in page (this may take a moment)")
driver.open(CHECKIN_URL)
self._take_debug_screenshot(driver, "after_page_load.png")
driver.click("(//div[@data-qa='placement-link'])[2]")
return driver

def _headers_listener(self, data: JSON) -> None:
Expand Down

0 comments on commit e28f4a6

Please sign in to comment.