资源简介
python/selenium 自动完成滑块拼图验证码_需要有python2.7.9以上,selenium3.5
代码片段和文件信息
# -*- coding:utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
import os
import requests
import hashlib
import urllib
import base64
import json
import sys
import win32api
import win32con
from PIL import Image
from PIL import ImageEnhance
def pixel_equal(image1 image2 x y):
“““
判断两个像素是否相同
:param image1: 图片1
:param image2: 图片2
:param x: 位置x
:param y: 位置y
:return: 像素是否相同
“““
# 取两个图片的像素点
pixel1 = image1.load()[x y]
pixel2 = image2.load()[x y]
threshold = 60
if abs(pixel1[0] - pixel2[0]) < threshold and abs(pixel1[1] - pixel2[1]) < threshold and abs(
pixel1[2] - pixel2[2]) < threshold:
return True
else:
return False
def get_gap(image1 image2):
“““
获取缺口偏移量
:param image1: 不带缺口图片
:param image2: 带缺口图片
:return:
“““
left = 0
for i in range(left image1.size[0]):
for j in range(image1.size[1]):
if not pixel_equal(image1 image2 i j):
left = i
return left
return left
def md5str(str):
m = hashlib.md5(str.encode(encoding = ‘utf-8‘))
return m.hexdigest()
def md5(byte):
return hashlib.md5(byte).hexdigest()
class DamatuApi():
ID = ‘50561‘
KEY = ‘9ec2ea230a83f411f71c8ae53360251d‘
HOST = ‘http://api.dama2.com:7766/app/‘
def __init__(self username password):
self.username = username
self.password = password
def getSign(selfparam = b‘‘):
return (md5(bytes(self.KEY)+bytes(self.username) + param))[:8]
def getPwd(self):
return md5str(self.KEY + md5str(md5str(self.username)+ md5str(self.password)))
def decodeUrl(selfurltype):
data = {‘appID‘:self.ID
‘user‘:self.username
‘pwd‘:self.getPwd()
‘type‘:type
‘url‘:urllib.quote(url)
‘sign‘:self.getSign(url.encode(encoding = ‘utf-8‘))
}
re = requests.post(“http://api.dama2.com:7766/app/d2Url“ data = (data))
jres = json.loads(re.text)
print jres
Vcode = jres[“result“]
print Vcode
return Vcode
def deccode(selffilePathtype):
f = open(filePath ‘rb‘)
fdata = f.read()
filedata = base64.b64encode(fdata)
f.close()
data = {‘appID‘: self.ID
‘user‘: self.username
‘pwd‘: self.getPwd()
‘type‘: type
‘fileDatabase64‘: filedata
‘sign‘: self.getSign(fdata)
}
re = requests.post(“http://api.dama2.com:7766/app/d2File“ data = (data))
jres = json.loads(re.text)
print jres
Vcode = jres[“result“]
print Vco
相关资源
- Python-BDD100K大规模多样化驾驶视频数据
- Instant Pygame for Python Game Development How
- Biopython Tutorial
- Think Python 2nd
- 一个小小的表白程序(python)
- Python课堂笔记(高淇400集第一季)
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
评论
共有 条评论