-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
62 lines (42 loc) · 1.48 KB
/
app.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
from extension import Extension
from seleniumbase import Driver
import os
class Browser():
def __init__(self,
target_url: str) -> None:
self.target_url = target_url
self.extension_dir = os.getcwd() + '\\1.9.9_0' # 1.9.9_0 Newest extension version
self.session = self.spawn_browser()
self.ext = Extension(self.session)
def spawn_browser(self):
driver = Driver(
browser = 'chrome',
headless = False,
headless2 = self.headless,
incognito = True,
dark_mode = True,
devtools = False,
uc = True,
extension_dir=self.extension_dir
)
driver.open(self.target_url)
return driver
def open_page(self, url: str) -> None:
self.session.open(url)
def refresh(self) -> None:
self.session.refresh()
def get_page_source(self) -> str:
return self.session.page_source
def get_current_url(self) -> str:
return self.session.current_url
def get_page_title(self) -> str:
return self.session.title.lower()
def quit_browser(self) -> None:
print('Quitting browser...')
self.session.quit()
if __name__ == '__main__':
browser = Browser(target_url='https://google.com',
headless=False,
proxy=None)
print(browser.ext.extension_state())
print(browser.get_current_url())