Python обход капчи пазл

recaptcha-puzzle

John was the first writer to have joined pythonawesome.com. He has since then inculcated very effective writing and reviewing culture at pythonawesome which rivals have found impossible to imitate.

Grading tools for Advanced NLP (11-711)

State-of-the-art deep learning and self-supervised learning algorithms for tabular data using PyTorch

You might also like.

TikTok Account Creator with Python Selenium

TikTok Account Creator 🚀 Create endless amounts of TikTok Accounts. 🚀 🏗 Manage your TikTok Accounts. 🏗 Features Random input Password Save Account details after Creation in .cvs file Full Auto Account Creation 🤖 Getting Started This script

Examples for opencv G-API

A Python library which can extract facial attributes using OpenCV/Deep Learning of the person (face) in a picture or from webcam

A Python library which can extract facial attributes using OpenCV/Deep Learning of the person (face) in a picture or from webcam.

Image to wave art converter using python with the help of OpenCV & Numpy modules

Recaptcha Resolver with Python

Extracts a subimage that contains a subtitle using opencv

Naruto Hand Gesture Recognition with OpenCV and Transfer Learning

Python Awesome is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. As an Amazon Associate, we earn from qualifying purchases.

Читайте также:  Php cli передача параметров

Источник

Python&selenium solution for sliding puzzle captchas

Many web sites are directly with the help of third-party plug-ins, that is, a kind of solution.

The author encountered this kind of puzzle verification code is actually a plurality of small fragments after recombination into a whole, the first to grab the small fragments on the website and download to the local

Let’s get the general idea straight:

Get all the fragments —- find out their sequence logic —— find out the serial number of the small fragment containing the true location of the dark color —— Calculate the distance —- based on the width and up and down of each fragment and the serial number of the dark piece using Selenium move the slider to the right to this distance

Import necessary packages directly from code forerunner:

# -*- coding:utf-8 -*- import colorsys import urllib,os,uuid,re,time from PIL import Image from selenium.webdriver.common.action_chains import ActionChains from selenium import webdriver Copy the code

Capture it and download it locally

def create(locapath,fileName): filePath=locapath+'/'+fileName if not os.path.exists(filePath): file=open(filePath,'a+') file.close() return filePath def downloadImg(): list = openBrowser() for i in range(2): fileName = str(i) + '_test.jpg' urllib.urlretrieve(list[i], create('/Users/zijiawang/Downloads/', Sleep (3) def openBrowser(): global WZJ WZJ = webdriver.firefox () wzj.get(' https://. ') image1_url = wzj.find_elements_by_class_name('gt_cut_bg_slice')[0].get_attribute('style') image1_url=image1_url[23:-38] image2_url = wzj.find_elements_by_class_name('gt_cut_fullbg_slice')[0].get_attribute('style') image2_url=image2_url[23:-38] return [image1_url,image2_url]Copy the code

Splits and retrieves RGB colors

ef getcolor(image): list = [[x,y] for x in range(26) for y in range(2)] listt = [] colors = [] for i in range(len(list)): L = list [I] [0] [I] * 12 + 12 w = list are 58 + [1] * 58 listt. Append ([12 * 0.25 + I / 2 * 12, 58 * 0.25 + ((I + 10) % 2) * 58]) listt. Append ([12 * 0.25 + I / 2 * 12, 58 * 0.75 + ((I + 10) % 2) * 58]) listt. Append ([12 * 0.75 + I / 2 * 12, 58 * 0.25 + ((I + 10) % 2) * 58]) listt. Append ([12 * 0.75 + I / 2 * 12, 58 * 0.75 + ((I + 10) % 2) * 58]) for I in range (len (listt)) : colors.append(image[listt[i][0],listt[i][1]]) return colorsCopy the code

Look for different numbers of small fragments

Def deferent (): deferent = [] for I in range(208): if abs(color1[I][2] -color2 [I][2]) 20: print "" ',color1[i][2]-color2[i][2] deferent.append(i) # print ([i,abs(color1[i][0] - color2[i][0]),abs(color1[i][1] - color2[i][1]),abs(color1[i][2] - color2[i][2])]) return deferent def getUPDOWN(): deferent = getDeferent() xlist = [] ylist = [] for i in deferent: if (i / 4) % 2 == 0: xlist.append(i) else: ylist.append(i) uplist = [] downlist = [] for i in xlist: uplist.append(i / 4) for i in ylist: downlist.append(i / 4) for i in range(len(uplist)): uplist[i] /= 2 for i in range(len(downlist)): downlist[i] /= 2 func = lambda x, y: x if y in x else x + [y] up = reduce(func, [[], ] + uplist) func = lambda x, y: x if y in x else x + [y] down = reduce(func, [[], ] + downlist) return up,downCopy the code

Write the permutation method, will use

def bubble(l): for index in range(len(l) - 1, 0 , -1): for two_index in range(index): if l[two_index] l[two_index + 1]: l[two_index], l[two_index + 1] = l[two_index + 1], l[two_index] return l Copy the code

The final analysis, assemble source code

def end(): orders = getUPDOWN() orderx = orders[0] ordery = orders[1] print 'x:',orderx print 'y:',ordery orderX = [145, 157, 277, 265, 169, 181, 253, 241, 97, 109, 301, 289, 73, 85, 37, 25, 1, 13, 133, 121, 49, 61, 229, 217, 193, 205] orderY = [157, 145, 265, 277, 181, 169, 241, 253, 109, 97, 289, 301, 85, 73, 25, 37, 13, 1, 121, 133, 61, 49, 217, 229, 205, 193] print u'X:',orderX print u'Y:',orderY for x in range(26): orderX[x] -= 1 orderX[x] /= 12 for y in range(26): orderY[y] -= 1 orderY[y] /= 12 endX = [] endY = [] for i in range(len(orderX)): for j in range(len(orderx)): if orderx[j] == orderX[i]: endX.append(i) break for i in range(len(orderY)): for j in range(len(ordery)): if ordery[j] == orderY[i]: endY.append(i) break print 'endx:',endX print 'endy:',endY os.remove('/Users/zijiawang/Downloads/0_test.jpg') OS. Remove ('/Users/zijiawang/Downloads / 1 _test. JPG ') all = [] all = endX + endY # print 'all:' all # system up to five experimental func = lambda x, y: x if y in x else x + [y] all_old = reduce(func, [[], ] + all) # print 'all_old:',all_old all_end =bubble(all_old) print 'all_end:',all_end duandata = 1000 for i in range(1,len(all_end)): if all_end[i]-1 in all_end: pass else: Duandata = all_end[I] print u',duandata guess =[] if duandata! = 1000: if endX ! = [] and endY! =[]: print u' breakpoint 1' guess =[duandata,all_end[0]] elif endX ==[]: print u' breakpoint 2 'guess =[duandata,all_end[0]] elif endX ==[] Print u' breakpoint 2' guess = [duandata, endY[0]] elif endY == []: print u' breakpoint 3' guess = [duandata, endX[0]] else: print u' breakpoint 3' guess = [duandata, endX[0]] else: Print u' print u' guess =[all_end[0]] end_guess =[] print u' print u' in guess: end_guess.append(i * 12 - 38) end_guess.append(i * 12 - 28) end_guess.append(i * 12 - 20) end_guess.append(i * 12 - 17) End_guess. Append (I * 12-15) print u',end_guess return end_guessCopy the code
if __name__ == '__main__': downloadImg() color1 = getcolor(Image.open('/Users/zijiawang/Downloads/0_test.jpg').load()) color2 = getcolor(Image.open('/Users/zijiawang/Downloads/1_test.jpg').load()) guess = end() for i in guess: print i,wzj.title try: ele = wzj.find_element_by_xpath('//div[@class="gt_slider_knob gt_show"]') except: ele = wzj.find_element_by_xpath('//div[@class="gt_slider_knob gt_show moving"]') ActionChains(wzj).click_and_hold(ele).perform() ActionChains(wzj).move_to_element_with_offset(ele, 0,i).perform() Copy the code

Because each site is similar, here do not write the specific test site, so as not to cause pressure. This algorithm is highly customizable and requires some parameters to be changed for other sites, but the code comments are small. Need comment, don’t understand the place please leave a message.

Читайте также:  Excelling in excel with java

Источник

Оцените статью