How to use a crawler to crack sliding verification code

醉折花枝作酒筹
Release: 2021-05-12 15:35:51
forward
3356 people have browsed it

This article will introduce to you how to use Python to crack the sliding verification code. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to use a crawler to crack sliding verification code

When doing crawling, you will always encounter various anti-crawling restrictions. The first line of defense against crawling often appears at login. In order to limit the automatic login of crawlers, Each family tried their best, as the saying goes, the higher the Tao is, the higher the devil is.

Today I will share a case of how to simply handle the verification code of sliding pictures.

How to use a crawler to crack sliding verification code


Login verification like this, where you drag the slider to coincide with the notch in the picture, is common on many websites or APPs because it is more accurate for real people. The user experience is friendly and easy to identify. At the same time, it can also intercept most primary crawlers.

As a python crawler, how to automatically complete this verification process correctly?

Let’s analyze it first. The core problem is actually how to find the location of the target gap. Once we know the location, we can use tools such as selenium to complete the dragging operation.

We can use opencv to solve this problem. The main steps are:

How to use a crawler to crack sliding verification code


What is opencv?

OpenCV (Open Source Computer Vision Library) is an open source computer vision library. The main algorithms involve image processing, computer vision and machine learning related methods. It can be used to develop real-time image processing, computer vision and pattern recognition programs. .

Direct installation

First perform Gaussian blur processing on the image. The main function of Gaussian blur is to reduce the noise of the image and is used in the pre-processing stage.

The effect after processing

How to use a crawler to crack sliding verification code

#Then use Canny edge detection to get a binary value containing "narrow boundary" image. The so-called binary image is a black and white image, only black and white.

Contour Detection

Find all the contours and use red lines The frame is drawn and marked, and it can be seen that there are dozens of outlines, large and small.

How to use a crawler to crack sliding verification code

The remaining problem is easy to solve. We only need to calculate the area of ​​the outline or By limiting the perimeter range, the location of the target outline can be filtered out, provided that the outline size of the target location is predetermined.

The area of ​​the outline is between 6000 and 8000, and the perimeter is between 300 and 500. Finally, use the enclosing rectangle to obtain the coordinate position, width and height of the outline. .

How to use a crawler to crack sliding verification code

The target position is found as above, the remaining work is to move the slider to the specified position

Related free learning recommendations: python video tutorial!

The above is the detailed content of How to use a crawler to crack sliding verification code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!