123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- from VerificationCode.mcbbs.SignIn import main_sign_in
- from VerificationCode.mcbbs.reply import reply
- from timing.time import set_time
- 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, WebDriverException
- import time
- import threading
- import random
- def main():
- threads = [threading.Thread(target=main_reply), threading.Thread(target=main_tasks_and_sign)]
- for t in threads:
- t.start()
- print(t)
- def main_reply():
- while True:
- set_time(one_reply, (1,), " 08:00:00")
- set_time(one_reply, (0,), " 12:00:00")
- set_time(one_reply, (0,), " 16:00:00")
- set_time(one_reply, (0,), " 20:00:00")
- set_time(one_reply, (0,), " 00:00:00")
- time.sleep(86400)
- def one_reply(flag):
- cookies = include_all_cookies()
- for cookie_path in cookies:
- while True:
- try:
- driver = webdriver.Chrome()
- if not login(driver, cookie_path):
- driver.quit()
- break
- urls = ['https://www.mcbbs.net/forum-texture-%d.html',
- 'https://www.mcbbs.net/forum-accessories-%d.html',
- 'https://www.mcbbs.net/forum-map-%d.html',
- 'https://www.mcbbs.net/forum-mapcarry-%d.html',
- 'https://www.mcbbs.net/forum-mapchat-%d.html',
- 'https://www.mcbbs.net/forum-moddiscussion-%d.html',
- 'https://www.mcbbs.net/forum-modtutorial-%d.html',
- 'https://www.mcbbs.net/forum-mod-%d.html',
- 'https://www.mcbbs.net/forum-modpack-%d.html',
- 'https://www.mcbbs.net/forum-multiplayer-%d.html',
- 'https://www.mcbbs.net/forum-servermod-%d.html',
- 'https://www.mcbbs.net/forum-serverpack-%d.html',
- 'https://www.mcbbs.net/forum-gameplay-%d.html']
- if flag == 1:
- time.sleep(10)
- r = random.randint(1, 30)
- r = str(r)
- reply(driver,
- 'https://www.mcbbs.net/forum-chat-' + r + '.html')
- i = 2
- while i >= 1:
- time.sleep(10)
- url_num = random.randint(0, 12)
- temp = urls[url_num]
- r = random.randint(1, 5)
- url = temp % r
- reply(driver, url)
- i = i - 1
- driver.quit()
- except NoSuchWindowException:
- print('except NoSuchWindowException')
- continue
- except WebDriverException:
- print('except WebDriverException')
- continue
- else:
- break
- def main_tasks_and_sign():
- while True:
- tasks()
- time.sleep(86400)
- def tasks():
- driver_another = webdriver.Firefox()
- set_time(get_tasks_and_sign_in, (driver_another,), " 07:30:00")
- set_time(final_complete_tasks, (driver_another,), " 19:30:00")
- def get_tasks_and_sign_in(driver):
- while True:
- try:
- cookies = include_all_cookies()
- for cookie_path in cookies:
- if not login(driver, cookie_path):
- continue
- while True:
- try:
- main_sign_in(driver)
- get_new_tasks(driver)
- except WebDriverException:
- continue
- else:
- break
- except NoSuchElementException:
- continue
- else:
- break
- def final_complete_tasks(driver):
- while True:
- try:
- cookies = include_all_cookies()
- for cookie_path in cookies:
- if not login(driver, cookie_path):
- continue
- complete_tasks(driver)
- except NoSuchElementException:
- continue
- else:
- break
- if __name__ == '__main__':
- main()
|