程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

One family, one pier, teach you how to use Python to rob Bing Dwen Dwen

編輯:Python

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 ~).

1、 Prepare the environment

1.1 Based on the environment -Python

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 .

1.2 Creating a virtual environment , Installation project dependency

Open the terminal /CMD after , Follow the instructions below , Line by line :

  • Enter project directory /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
  • Enter the following command , You can create a virtual environment , By default, files related to the virtual environment will be stored in .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
  • Enter the following command , First into the virtual environment , Then install the third-party dependency package .
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 .

2、 Get project code

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

3、 Look at the source code

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 .

  • Start command line parameter resolution

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 .

  • Taobao rush buying script

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

4、 Run the project

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 ~

5、 Finally, let's talk

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 ”.


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved