123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- from ..GetImage import get_vc_image
- from ..ttshitu import base64_api
- from selenium.webdriver.common.action_chains import ActionChains
- import time
- def sign_in_vc(driver):
- url = 'https://www.mcbbs.net/plugin.php?id=dc_signin'
- driver.get(url)
- get_to_sign_in(driver)
- image = get_image(driver)
- image = image.convert('RGB')
- image.save('D:\同步文件\课程文件\文档\mcbbs搞事\AutoTool\VerificationCode\image.jpg')
- img_path = 'D:\同步文件\课程文件\文档\mcbbs搞事\AutoTool\VerificationCode\image.jpg'
- result = base64_api(uname='Shellmiao', pwd='sBif.9MMF8Pa', img=img_path)
- print(result)
- click_vc_words(driver, get_points(result))
- def get_points(result):
- groups = result.split('|')
- locations = [[int(number) for number in group.split(',')] for group in groups]
- return locations
- # 验证码的点击和确认
- def click_vc_words(driver, locations):
- element = driver.find_element_by_class_name('geetest_widget')
- for location in locations:
- # 因为笔记本缩放是250%,所以坐标要除以2.5
- location[0] = location[0] * 0.5
- location[1] = location[1] * 0.5
- print(location)
- ActionChains(driver).move_to_element_with_offset(element, location[0], location[1]).click().perform()
- time.sleep(1)
- time.sleep(2)
- button = driver.find_element_by_class_name('geetest_commit_tip')
- ActionChains(driver).move_to_element(button).click().perform()
- time.sleep(2)
- def get_to_sign_in(driver):
- sign_in_button(driver)
- sign_in(driver)
- def sign_in_button(driver):
- button = driver.find_element_by_link_text('签到')
- ActionChains(driver).move_to_element(button).click().perform()
- def sign_in(driver):
- time.sleep(2)
- button = driver.find_element_by_id('emot_1')
- ActionChains(driver).move_to_element(button).click().perform()
- time.sleep(2)
- submit = driver.find_element_by_name('signpn')
- ActionChains(driver).move_to_element(submit).click().perform()
- def get_image(driver):
- time.sleep(2)
- element = driver.find_element_by_class_name('geetest_widget')
- vc_image = get_vc_image(element)
- return vc_image
|