Python entry-Level identification verification code

Source: Internet
Author: User
Previously: This article refers to the content of the blogger last summer time to do, has not sunk his heart to write their own experience on paper, fortunately, this holiday leisure time more, thinking can write how much is how much, so there is this article.

Verification code? Can I hack it too?

On the introduction of the verification code is not much said, a variety of verification code in people's lives from time to time will come out, Bo Lord as a student of Northeastern University, the most daily contact is the Academic Office system verification code.
East of the verification code has been the students spit groove, too difficult to enter, not only the case-sensitive, some time you entered the correct, but prompted an error, and this time 禁止你的左键复制 perhaps the bounce out.
(However, the Academic affairs Office of the 16-17 academic year changed the contents of the verification code, which is more convenient for human operation.) )

It can be seen that the academic Office verification Code is very regular, each alphanumeric size position shape and so on are fixed, which is suitable for beginners without foundation to identify the verification code.

Identification method

Analog landing has complicated steps, and here we are only responsible for returning an answer string based on an input CAPTCHA image.

We know that the verification code in order to make interference, will make the picture into a colorful appearance, and we first is to remove these disturbances, this step needs to be constantly tested, enhance the color of the picture, increase contrast and so can help.

After a variety of pictures of the operation, finally found a more perfect solution to eliminate interference. We can see that after removing the interference, we will get a very pure black and white character picture in the best case. A picture has four characters, there is no way to put four characters all at once, you need to cut the picture, cut to each small picture only one character, and then each image to identify.

The next step is to identify the text, we first convert the resulting small graph into a matrix of 01, each representing a character.
Like the matrix of the number six.

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,]

Far from the past, squinting eyes still can distinguish out.
Because the code of the Office of the East is very regular, each number is located in a fixed position, so there is no need to deal with any machine learning algorithm, just simple to do a matrix of the comparison can be, in all the implementation of the matrix to find the highest similarity of the matrix can be, here is a variety of comparison methods, Anyway, the data can be easily recognized correctly.

At this point, our verification code identification work is over.

Summary

This time the verification code identification is mainly used in Python pil for picture operation, to simulate the login to automatically fill out the code of all codes please see

Xfangfang ' s Github

Related Article

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.