-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdrivers.py
More file actions
54 lines (43 loc) · 1.92 KB
/
Copy pathdrivers.py
File metadata and controls
54 lines (43 loc) · 1.92 KB
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
# -*- coding: utf-8 -*-
import platform
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from notifier import Notifier
class Driver(webdriver.Chrome):
def __init__(self):
options = webdriver.ChromeOptions()
# TODO cloud9で動かす場合はONにする
# options.add_argument('--headless')
# options.add_argument('--disable-gpu')
options.add_argument('--window-size=1920,1080')
options.add_argument('--start-maximized')
options.add_experimental_option('w3c', False)
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument('--allow-running-insecure-content')
options.add_argument('--disable-web-security')
options.add_argument('--disable-desktop-notifications')
options.add_argument('--disable-default-apps')
options.add_argument('--disable-extensions')
options.add_argument('--disable-infobars')
options.add_argument('--test-type')
options.add_argument('--log-level=2')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36')
if platform.system() != 'Windows':
super().__init__(executable_path='./chromedriver', options=options)
else:
super().__init__(options=options)
def login(self):
raise NotImplementedError
def search(self, keyword):
raise NotImplementedError
def follow(self):
raise NotImplementedError
def like(self):
raise NotImplementedError
def notify(self, text):
Notifier.notify_discord(text)
def _wait_until(self, method, timeout=10):
return WebDriverWait(self, timeout).until(method)