|
|
@ -53,7 +53,7 @@ class WeiboCookies(): |
|
|
|
""" |
|
|
|
""" |
|
|
|
try: |
|
|
|
try: |
|
|
|
return bool( |
|
|
|
return bool( |
|
|
|
WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.CLASS_NAME, 'drop-title')))) |
|
|
|
WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.CLASS_NAME, 'main-wrap')))) |
|
|
|
except TimeoutException: |
|
|
|
except TimeoutException: |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
@ -67,6 +67,7 @@ class WeiboCookies(): |
|
|
|
except TimeoutException: |
|
|
|
except TimeoutException: |
|
|
|
print('未出现验证码') |
|
|
|
print('未出现验证码') |
|
|
|
self.open() |
|
|
|
self.open() |
|
|
|
|
|
|
|
return '' |
|
|
|
time.sleep(2) |
|
|
|
time.sleep(2) |
|
|
|
location = img.location |
|
|
|
location = img.location |
|
|
|
size = img.size |
|
|
|
size = img.size |
|
|
@ -204,16 +205,6 @@ class WeiboCookies(): |
|
|
|
'content': '用户名或密码错误' |
|
|
|
'content': '用户名或密码错误' |
|
|
|
} |
|
|
|
} |
|
|
|
# 如果不需要验证码直接登录成功 |
|
|
|
# 如果不需要验证码直接登录成功 |
|
|
|
if self.login_successfully(): |
|
|
|
|
|
|
|
cookies = self.get_cookies() |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
'status': 1, |
|
|
|
|
|
|
|
'content': cookies |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
# 获取验证码图片 |
|
|
|
|
|
|
|
image = self.get_image('captcha.png') |
|
|
|
|
|
|
|
numbers = self.detect_image(image) |
|
|
|
|
|
|
|
self.move(numbers) |
|
|
|
|
|
|
|
if self.login_successfully(): |
|
|
|
if self.login_successfully(): |
|
|
|
cookies = self.get_cookies() |
|
|
|
cookies = self.get_cookies() |
|
|
|
return { |
|
|
|
return { |
|
|
@ -221,12 +212,23 @@ class WeiboCookies(): |
|
|
|
'content': cookies |
|
|
|
'content': cookies |
|
|
|
} |
|
|
|
} |
|
|
|
else: |
|
|
|
else: |
|
|
|
return { |
|
|
|
# 获取验证码图片 |
|
|
|
'status': 3, |
|
|
|
image = self.get_image('captcha.png') |
|
|
|
'content': '登录失败' |
|
|
|
numbers = self.detect_image(image) |
|
|
|
} |
|
|
|
self.move(numbers) |
|
|
|
|
|
|
|
if self.login_successfully(): |
|
|
|
|
|
|
|
cookies = self.get_cookies() |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
'status': 1, |
|
|
|
|
|
|
|
'content': cookies |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
'status': 3, |
|
|
|
|
|
|
|
'content': '登录失败' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|
result = WeiboCookies('14773427930', 'x6pybpakq1').main() |
|
|
|
result = WeiboCookies('14773427930', 'x6pybpakq1', 'Chrome').main() |
|
|
|
print(result) |
|
|
|
print(result) |
|
|
|