Hello everyone , I'm an old watch ~
In recent days, bingdundun has become very popular , To what extent is the fire ? The circle of friends is full of lovely photos of Bing Dwen Dwen every day , Official account teach programming to draw Bing Dwen Dwen , The video numbers are all winter Olympics videos , There are Bing Dwen Dwen everywhere , The most direct manifestation is : The major e-commerce platforms simply can't grab the dolls around Bing Dwen Dwen .
On Github Search for : Ice mound , There are also various source codes that teach you to draw Bing Dwen Dwen .
What one likes to do is what Ming Lao shares in the group 3d edition , Simple and clear 、 Cute high end .
however , No matter how good the painting is, it can't be better than the real one , therefore , This article will share another open source project : Taobao rush buying script , Project the author Charles
I also shared the project code introduction article on my official account : It is said that Bing Dwen Dwen is very popular recently ? Let's take you to write a buying script !
Project code address :https://github.com/CharlesPikachu/DecryptLogin/blob/master/examples/taobaosnap/taobaosnap.py
This article mainly teaches you how to run this script ~ Thanks to the author of this open source project Charles
, Here's another one , This author's open source library DecryptLogin
Super excellent , It can be used to simulate login to some common websites , Then we can easily use the code to realize automatic operation 、 Reptiles , Or like the snapping up script to share today ( Next time I will share with you how to use ~).
First, you need to install your computer Python Environmental Science , And it's installed Python development tool .
If you haven't installed , You can refer to the following article :
If only Python To process data 、 Reptiles 、 Data analysis or automated scripts 、 Machine learning, etc , It is recommended to use Python Based on the environment +jupyter that will do , Installation and use reference Windows/Mac install 、 Use Python Environmental Science +jupyter notebook
If you want to use Python Conduct web Project development, etc , It is recommended to use Python Based on the environment +Pycharm, Installation and use reference :Windows Lower installation 、 Use Pycharm course , It's all over and Mac Let's play around Python- install & Use Python/PyCharm .
I use it locally Python 3.10.0
, And then use pipenv
Manage virtual environments , About pipenv
You can see I use Pipenv To manage the project environment , Cool in capitals .
Open the terminal /CMD after , Follow the instructions below , Line by line :
/Users/xks/Desktop/Project/crawler
, Create a new project directory bdd_tb
, Then enter bdd Project directory , Create a new one .venv
Folder , Store the virtual environment in the back .cd /Users/xks/Desktop/Project/crawler && mkdir bdd_tb cd bdd_tb && mkdir .venv
.venv
In the folder , Create good after , It is suggested to modify Pipfile
Medium pip Download source , Specific operation Pipenv Manage project virtual environment tutorial .pipenv install
pipenv shell pipenv install pyttsx3 DecryptLogin requests prettytable
Attention! , This terminal /CMD Don't turn it off yet , After downloading the code, continue to run the code here .
It can be in the official account 「 Jane said Python」 reply : Ice mound Get the source cloud disk download address , Be careful , Put the downloaded source file into Project folder bdd_tb
in .
bdd_tb ├── .venv # Virtual environment storage directory ├── Pipfile # Virtual environment profile ├── Pipfile.lock # Virtual environment profile ├── bdd_tb.py # Project code file └── cookie_cache.pkl # After running the project , Will first ask to scan the code to log in to Taobao , After login, it will automatically generate
The whole code is mainly divided into 3 part ( It does not include the front guide package ): Start command line parameter resolution 、 Taobao rush buying script 、 function .
We can see , The author mainly provides two parameters interval
( The time interval to check whether the goods can be purchased when buying goods in a rush ),key
(Server Sauce key, A wechat message reminder service ).
among interval
Is a parameter that must be specified when the project runs , Theoretically interval
The smaller the value, the better , But it's too small , Too many requests per unit time , There's also the risk of being blocked , So the best way is , Wait until the pre-sale begins 1 minute ( Or half a minute ) To start the program ,interval
Set it to a point where you feel ok Value , Note that the unit is seconds .
The author wrote it all in TaobaoSnap
Class , It mainly includes the whole rush buying process and logic implementation , Include : Sign in 、 Choose to snap up goods 、 Functions such as rush purchase are realized .
Part of the code
Necessary condition : Before running the project , You need to add the items you want to buy to your shopping cart ( Don't have too many items in the shopping cart ).
Open the terminal /CMD, Enter project directory , And then into the virtual environment .
cd /Users/xks/Desktop/Project/crawler/bdd_tb pipenv shell
In a virtual environment , Enter the following code to run the project , I designated interval
by 2s( I think it was before the pre-sale 20s Left and right start procedures ):
python bdd_tb.py --interval 2
After successful startup , A QR code will pop up , Use the mobile phone Taobao to scan the code and log in , After successful login , At the terminal /CMD Print out your shopping cart item name list in , Enter the item you want to buy id You can start the rush purchase , As shown in the figure below .
After successful rush purchase , You will be prompted with the content , The author also set up a computer voice prompt , It's very intimate ~
See the screenshot above , You may ask me : Did you get Bing Dwen Dwen ? No, .
It is true that both the output and voice prompts me : Panic buying , Order submitted ; But when I went to Taobao , There is no... In the agency payment .
The code should be ok ( Tested other products ), It feels like it's officially set : The order is payment minus inventory , Orders do not occupy inventory
Caused by the , When I opened Taobao for payment , There has been a 2000 Someone paid before me , So there is no stock Naturally, it will not appear in the pending payment .
At present, the better method is : Open the pending payment at the same time of starting the rush purchase , Keep refreshing , After the code is placed , Payment can be made manually in time . Or study later , Can you add an automatic payment ~
You are welcome to exchange your ideas in the comment area , It's not easy to code words , Welcome to thumb up Looking at forward Message support .
Thank you again for Charles Open source this project ,“ 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 ”.