current position:Home>Learning this Python library can reduce at least 100 lines of code

Learning this Python library can reduce at least 100 lines of code

2022-01-29 18:03:07 Dream eraser

Little knowledge , Great challenge ! This article is participating in 「 A programmer must have a little knowledge 」 Creative activities

This article has participated in  「 Digging force Star Program 」 , Win a creative gift bag , Challenge creation incentive fund .

Write it at the front

Dream eraser , One who aspires to become IT Circle influential people , To this day , I have achieved 10%

I'm going to write a series of articles about reptiles today , In the process of browsing, I reached Zhihu , I saw a lot of fitness girls , Okay , Good figure , I want to climb down with a flash of light in my heart , The archive . As a small dish that has barely been introduced to reptiles , This simple one doesn't work , After an operation , Found the card on Zhihu login , I originally planned to write a simulated Login , Then I thought about it , I don't want to build wheels anymore , Go to github Don't you find a ready-made one on the ?

So , With this article

DecryptLogin library

Project source code…

This project is a library used to realize various login , And the statement of the project is very smelly

Project statement This project is only for python Lovers learn to use , If the author finds that the project has been used in any improper way , The item will be deleted immediately .

I hope you can make rational use of the project

Okay , This project is for lovers , If you do something bad , I'll delete this item , very nice.

How about a library , Remember how we judged , See if his documents are well written , Good documentation , The library is generally not bad

Chinese document…

Open it and have a look , It is found that there are still many supported platforms , And this library is 3 It was still updated days ago ( It's today 2020 year 6 month 19 Japan ), The proof library is still under maintenance .

Python course , Reptile tutorial

Code time

The specific details are not repeated , This library can run is the basic premise , Walk up

pip install DecryptLogin --upgrade

setup script , Don't complain , What if you're wrong , Switch source , Of course, this library needs Python3.6 Above version

DecryptLogin Relevant dependent package requirements are as follows :

rsa >= 4.0 qrcode >= 6.1 pillow >= 6.0.0 requests >= 2.22.0 pycryptodome >= 3.8.1 requests_toolbelt >= 0.9.1 PyExecJS >= 1.5.1 ( Used in testing Node.js Version is v10.15.3)

Python course , Reptile tutorial

Then you can start quickly , The official documents are also very simple

Three lines of code to simulate login

This title , There's a line of code called goddess sitting at the same table…

After three lines of code , So caught off guard to succeed , Of course, I also entered a verification code in the process .

from DecryptLogin import login

lg = login.Login()
infos_return, session = lg.zhihu(username=' Your account number ', password=" Your password ")

 Copy code 

Python course , Reptile tutorial

What is more wonderful is that , Verification code processing can also support Docking of coding platform , This has been relatively perfect , The goal of our initial simulated Login is enough

from DecryptLogin import login

''' Define the verification code identification function '''
def crackvcFunc(imagepath):
    #  Open captcha image 
    img =
    #  Identification code image 
    result = IdentifyAPI(img)
    #  Return recognition results ( Known as digital verification code )
    return result

lg = login.Login()
infos_return, session = lg.zhihu(username='Your Username', password='Your Password', crackvcFunc=crackvcFunc)
 Copy code 

Written in the back

If you don't want to build wheels , It is possible to use the open source project directly , Of course, open his source code , Have a good analysis , Copy it , I can still learn a lot , Copying is the best at the beginning of learning , It is also the most effective way to learn

A lot of times , We can't solve the technical problem , It's not because we're not skilled , But because we don't know what to do

I hope you can hear from today that there is a DecryptLogin library .

copyright notice
author[Dream eraser],Please bring the original link to reprint, thank you.

Random recommended