import io
import json
import os
import random
import time
import traceback
from threading import Thread
import func_timeout
import requests
import selenium
from PIL import Image
from func_timeout import func_set_timeout
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
def login(email, passwd):
url = 'https://v2.freeyes.xyz/auth/login'
data = {
'email': email, 'passwd': passwd}
headers = {
'user-agent': None}
try:
r = requests.post(url, data=data, headers=headers, timeout=10)
except requests.exceptions.ReadTimeout:
pass
try:
if r.json()['ret'] == 0:
return
except json.decoder.JSONDecodeError:
return
cookies = r.cookies.get_dict()
print(cookies)
return cookies
class register:
__species = None
chrome = None
def __new__(cls, *args, **kwargs):
if not cls.__species:
cls.__species = object.__new__(cls)
cls.chrome = ChromeDriverManager().install()
return object.__new__(cls)
def __init__(self, code=None):
self.options = webdriver.ChromeOptions()
self.options.add_argument("--no-sandbox")
self.options.add_argument("--start-maximized")
self.__start_crop_image = False
self.__refresh = False
self.__success = False
self.__completed = False
if not code:
code = 'eId6'
self.url = f'https://v2.freeyes.xyz/auth/register?code={code}'
print(self.url)
def __del__(self):
self.__completed = True
try:
self.browser.close()
except (NameError, ImportError, AttributeError, selenium.common.exceptions.InvalidSessionIdException):
pass
del self
def __call__(self):
try:
return self.__reg()
except func_timeout.exceptions.FunctionTimedOut:
print('运行超时')
self.__del__()
except KeyboardInterrupt:
os._exit(
selenium过滑块验证码自动注册账号
最新推荐文章于 2023-05-16 14:39:54 发布
本文介绍如何利用Python的Selenium库自动化处理滑块验证码,实现账号的自动注册。详细步骤见GitHub项目的相关说明。
摘要由CSDN通过智能技术生成