Python entry-level recognition verification code

Source: Internet
Author: User
This article explains how to use python to identify the preference of the verification code: the content mentioned in this article was made by bloggers during the last summer vacation and has never been down to writing their experiences on paper, fortunately, there were many leisure days during this holiday and I thought about how much I could write, so I had this article.

Verification code? Can I crack it?

The introduction of verification codes is not much said. various verification codes may come out from time to time in people's lives. as a student of Northeastern University, the most frequently accessed verification codes are those of the academic affairs office system.
The verification code of Dongda has been swallowed up by students. it is too difficult to input. it is case-sensitive. sometimes, when you clearly enter the correct information, an error is Prompted. at this timeProhibit your left-click CopyMaybe the pop-up is coming.
(However, the academic office changed the content of the verification code in to facilitate human operations .)

It can be seen that the verification code of the academic affairs office is very regular, and the size and position of each letter and number are fixed. this is suitable for beginners without any foundation to identify the verification code.

Identification method

Simulated login involves complex steps. here, regardless of other operations, we only return an answer string based on an input verification code image.

We know that the verification code will make pictures colorful in order to make interference. The first thing we need to do is to remove these interference. this step needs to be continuously tested to enhance the color of the image, increasing the contrast can be helpful.

After a variety of operations on the image, we finally found a perfect solution to remove interference. We can see that after the interference is removed, we will get a very pure black/white image under optimal conditions. An image contains four characters, so you cannot recognize all the four characters at once. you need to crop the image into a single character in each small image, and then identify each image separately.

The next step is to recognize the text. First, we convert the obtained small image into a matrix represented by 01. each matrix represents one character.
For example, the matrix of number 6

num_6=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,]

Looking far away, you can still tell with your eyes wide.
Because the verification code of the Office of Academic Affairs of the East University is very regular, and each number is in a fixed position, it does not need to involve any machine learning algorithms, but simply performs a matrix comparison, you can find the matrix with the highest similarity among all the implemented matrices. the comparison methods here are diverse, and the data can be identified simply and correctly.

So far, our verification code recognition is over.

Summary

This verification code recognition mainly uses python PIL for image operations. please refer to all the codes for automatically entering the verification code during simulated login.

Xfangfang's Github

The above is the details of the python entry-level verification code. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.