|
@@ -5,7 +5,7 @@ from VerificationCode.mcbbs.task import get_new_tasks, complete_tasks
|
|
|
from selenium import webdriver
|
|
|
from loginTools.login import login
|
|
|
from loginTools.include_all_cookies import include_all_cookies
|
|
|
-from selenium.common.exceptions import NoSuchWindowException, NoSuchElementException
|
|
|
+from selenium.common.exceptions import NoSuchWindowException, NoSuchElementException, WebDriverException
|
|
|
import time
|
|
|
import threading
|
|
|
import random
|
|
@@ -30,13 +30,14 @@ def main_reply():
|
|
|
|
|
|
|
|
|
def one_reply():
|
|
|
- while True:
|
|
|
- try:
|
|
|
- driver = webdriver.Chrome()
|
|
|
- cookies = include_all_cookies()
|
|
|
- for cookie_path in cookies:
|
|
|
+ cookies = include_all_cookies()
|
|
|
+ for cookie_path in cookies:
|
|
|
+ while True:
|
|
|
+ try:
|
|
|
+ driver = webdriver.Chrome()
|
|
|
if not login(driver, cookie_path):
|
|
|
- continue
|
|
|
+ driver.quit()
|
|
|
+ break
|
|
|
time.sleep(10)
|
|
|
r = random.randint(1, 50)
|
|
|
r = str(r)
|
|
@@ -49,11 +50,15 @@ def one_reply():
|
|
|
r = str(r)
|
|
|
reply(driver, 'https://www.mcbbs.net/forum-mod-' + r + '.html')
|
|
|
i = i - 1
|
|
|
- driver.quit()
|
|
|
- except NoSuchWindowException:
|
|
|
- continue
|
|
|
- else:
|
|
|
- break
|
|
|
+ driver.quit()
|
|
|
+ except NoSuchWindowException:
|
|
|
+ print('except NoSuchWindowException')
|
|
|
+ continue
|
|
|
+ except WebDriverException:
|
|
|
+ print('except WebDriverException')
|
|
|
+ continue
|
|
|
+ else:
|
|
|
+ break
|
|
|
|
|
|
|
|
|
def main_tasks_and_sign():
|
|
@@ -75,8 +80,14 @@ def get_tasks_and_sign_in(driver):
|
|
|
for cookie_path in cookies:
|
|
|
if not login(driver, cookie_path):
|
|
|
continue
|
|
|
- main_sign_in(driver)
|
|
|
- get_new_tasks(driver)
|
|
|
+ while True:
|
|
|
+ try:
|
|
|
+ main_sign_in(driver)
|
|
|
+ get_new_tasks(driver)
|
|
|
+ except WebDriverException:
|
|
|
+ continue
|
|
|
+ else:
|
|
|
+ break
|
|
|
except NoSuchElementException:
|
|
|
continue
|
|
|
else:
|