-
Notifications
You must be signed in to change notification settings - Fork 480
/
Copy pathbot.py
38 lines (31 loc) · 1.03 KB
/
bot.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
#!/usr/bin/python
# coding: utf-8
from selenium import webdriver
import time, sys, json, selenium
# cd /bot/ && rq worker -v -u redis://:[email protected]:6379/
def add(url):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
# chrome_options.add_argument('--no-sandbox')
with open('config.json', 'r') as fp:
ADMIN_URL = json.load(fp)['admin_url']
client = webdriver.Chrome(chrome_options=chrome_options)
client.set_page_load_timeout(5)
client.set_script_timeout(5)
client.get(ADMIN_URL)
client.get(url)
i = 0
while 1:
try:
client.switch_to_alert().accept()
i += 1
if i > 1000:
break
except selenium.common.exceptions.NoAlertPresentException:
break
time.sleep(2)
client.quit()
if __name__ == '__main__':
add(sys.argv[1])