-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Browser.py
23 lines (19 loc) · 871 Bytes
/
Browser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import undetected_chromedriver as uc
from fake_useragent import UserAgent, FakeUserAgentError
# import os
# https://github.com/ultrafunkamsterdam/undetected-chromedriver
# Class used to create undetectable selenium bot
class Browser:
def __init__(self):
try:
ua = UserAgent()
self.user_agent = ua.random
except FakeUserAgentError:
self.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
options = uc.ChromeOptions()
options.add_experimental_option("prefs", { "profile.default_content_setting_values.notifications": 2})
# options.add_argument("--user-agent=" + self.user_agent)
self.bot = uc.Chrome(options=options)
self.bot.delete_all_cookies()
def getBot(self):
return self.bot