This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.py
62 lines (57 loc) · 3.34 KB
/
Config.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
from random import randint, random
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support import expected_conditions as EC
from fake_useragent import UserAgent
from pyshadow.main import Shadow
import undetected_chromedriver as uc
class ConfigClass:
def __init__(self):
# Configs
self.start_from = "lisbon" # Departing airport
self.destination = "Memmingen" # Arriving airport
self.chosen_day = (("23"), "2022-09") # Departing date
self.chosen_return = [("27", "28", "29"), "2022-09"] # Return date
self.get_cheapest = True # Select cheapest or best flights
self.add_nearby = True # Add nearby airports for destination
self.random_version = f'{randint(80, 103)}.0.{randint(2000, 5013)}.{randint(10, 53)}'
self.url = ["https://www.skyscanner.net", "https://www.skyscanner.net/sttc/px/captcha-v2/index.html",
"https://www.google.co.uk"]
self.create_file = True
# Driver options and user agent
# Browser configs to bypass bot detection
self.chrome_options = Options()
self.ua = UserAgent()
self.userAgent = self.ua.random
# self.chrome_options.page_load_strategy = "normal"
# self.chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
# self.chrome_options.add_experimental_option('useAutomationExtension', False)
# self.chrome_options.add_argument('--disable-blink-features=AutomationControlled')
self.chrome_options.add_argument("--start-maximized")
self.chrome_options.add_argument("--incognito")
# self.chrome_options.add_argument("--enable-javascript")
self.chrome_options.add_argument("--disable-extensions")
self.chrome_options.add_argument("--disable-infobars")
self.chrome_options.add_argument(f'user-agent={self.userAgent}')
# self.chrome_options.add_experimental_option("detach", True)
os.environ['GH_TOKEN'] = "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"
self.driver = uc.Chrome(options=self.chrome_options)
# self.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=self.chrome_options)
# self.driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
# "source": """
# Object.defineProperty(navigator, 'webdriver', {
# get: () => undefined})
# """
# })
# self.driver.header_overrides = {
# 'User-Agent': f'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{self.random_version} Safari/537.36'}
# self.driver.execute_cdp_cmd('Network.setUserAgentOverride', {
# "userAgent": f'Mozilla/5.0 (Windows NT 10.0; win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{self.random_version} Safari/537.36'})
shadow = Shadow(self.driver)