forked from mdmintz/undetected-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraw_easyjet.py
48 lines (47 loc) · 1.75 KB
/
raw_easyjet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from seleniumbase import SB
with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
url = "https://www.easyjet.com/en/"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.cdp.click_if_visible("button#ensCloseBanner")
sb.sleep(1.2)
sb.cdp.click('input[name="from"]')
sb.sleep(1.2)
sb.cdp.type('input[name="from"]', "London")
sb.sleep(0.6)
sb.cdp.click_if_visible("button#ensCloseBanner")
sb.sleep(0.6)
sb.cdp.click('span[data-testid="airport-name"]')
sb.sleep(1.2)
sb.cdp.type('input[name="to"]', "Venice")
sb.sleep(1.2)
sb.cdp.click('span[data-testid="airport-name"]')
sb.sleep(1.2)
sb.cdp.click('input[name="when"]')
sb.sleep(1.2)
sb.cdp.click('[data-testid="month"]:last-of-type [aria-disabled="false"]')
sb.sleep(1.2)
sb.cdp.click('[data-testid="month"]:last-of-type [aria-disabled="false"]')
sb.sleep(1.2)
sb.cdp.click('button[data-testid="submit"]')
sb.sleep(4.2)
sb.connect()
sb.sleep(1.2)
for window in sb.driver.window_handles:
sb.switch_to_window(window)
if "/buy/flights" in sb.get_current_url():
break
sb.click_if_visible("button#ensCloseBanner")
days = sb.find_elements('div[class*="FlightGridLayout_column"]')
for day in days:
if not day.text.strip():
continue
print("**** " + " ".join(day.text.split("\n")[0:2]) + " ****")
fares = day.find_elements("css selector", 'button[class*="flightDet"]')
if not fares:
print("No flights today!")
for fare in fares:
info = fare.text
info = info.replace("LOWEST FARE\n", "")
info = info.replace("\n", " ")
print(info)