When using the Python crawler to log in automatically, encountering the need to enter a graphics verification code, a relatively simple process is to use the Code platform identification Code.
Use over two dozen yards platform, coding rabbit and if fast, if the price is cheaper, the recognition rate is equal. If you need to register two account: Developer account and user account, user account is used to send identification request, the developer account can register the software ID, and to identify the request to bind, can participate in identifying the income of the return.
There are two ways to get the graphics verification code that are currently found:
0x01
You can get the picture directly in the grab bag: Send GET request can get the picture directly (PNG or JPG format), this case can use the content method of Request.get () return value, get picture file, use code platform to identify directly.
0x02
The picture is returned using base64 encryption:
For example, image contains an image file that has been Base64 encrypted. You can restore a picture in the following ways:
resp = self.s.get (URL, Headers=header, Verify=false, Timeout=10 =json.loads (resp.text) captchaid =resp_json.get (" captchaid " ) imagestr =resp_json.get (" image " ) imgdata =base64.b64decode (IMAGESTR) file
=open ( ' captcha.gif " ), " WB " ) file.write (Imgdata) file.close ()
Picture format is not necessarily a GIF, may be jpg or PNG, if the wrong write, the results can not be opened, the online image decoding web site to verify a piece of format.
Processing of graphics verification code in Python crawler