JD滑块验证码模拟登录

京东滑块验证码模拟登录操作:

import time
import random
import requests

from selenium import webdriver
from selenium.webdriver import ActionChains
from io import BytesIO
from PIL import Image
from collections import Counter

# 获取JD登陆页面
url = "https://passport.jd.com/new/login.aspx"
# 启动调试程序
browser = webdriver.Chrome(executable_path="D:\python\chromedriver\chromedriver.exe")


# 二值化,将所有的点位,全部换成0或255
def shape(w, h, image):
    tem = 0
    for x in range(w):
        for y in range(h):
            tem += image.getpixel((x, y))
    pixel_ave = tem / w / h * 0.7
    for x in range(w):
        for y in range(h):
            p = image.getpixel((x, y))
            if p < pixel_ave:
                image.putpixel((x, y), 0)
            else:
                image.putpixel((x, y), 255)
    return image


# 降噪处理
def reducenoise(image):
    w, h = image.size
    for x in range(0, 40):  # 处理最

你可能感兴趣的:(python,爬虫)