Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use selenium to realize Taobao just-in-time killing and grabbing order by python

Shulou Source: shulou.com Published: 2022-06-01 11:37:22 10月01日 Update

This article mainly introduces python how to use selenium to achieve Taobao on-time kill order related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this python how to use selenium to achieve Taobao just-in-time kill single article will have a harvest, let's take a look.

1. Installation of ChromeDriver

If you want to use Selenium to successfully call the Chrome browser to complete the corresponding operation, you need to use ChromeDriver to drive.

Before downloading, let's confirm the version of Chrome browser we use. We only need the same number of digits in the red box.

Choose according to your own operating system

It can be found in the Scripts folder under the Python installation path

2. Implementation code from selenium import webdriverimport timeimport datetime#: open the Chrome browser browser = webdriver.Chrome () def login (): # Open the home page of Taobao and log in to browser.get by scanning the code ("https://www.taobao.com") time.sleep (3) if browser.find_element_by_link_text"): browser.find_element_by_link_text ("Dear, please log in") Please log in to ") .click () print (f" Please log in as soon as possible ") time.sleep (10) def picking (method): # Open the shopping cart list page browser.get (" https://cart.taobao.com/cart.htm") time.sleep (3) # whether to select all shopping carts if method = = 0: while True: try: If browser.find_element_by_id ("J_SelectAll1"): browser.find_element_by_id ("J_SelectAll1"). Click () break except: print (f "Buy button not found") else: print (f "Please manually check the items to be purchased") Time.sleep (5) def buy (times): while True: now = datetime.datetime.now (). Strftime ('% Y-%m-%d% Hpurs% MRV% S.% f') print (now) # comparison time Click settlement if now > times: # Click the settlement button while True: try: if browser.find_element_by_id ("J_Go"): browser.find_element_by_id ("J_Go"). Click () Print (f "settlement successful Prepare to submit order ") break except: pass # Click submit order button while True: try: if browser.find_element_by_link_text ('submit order'): browser .find _ element_by_link_text ('submit order') .click () print (f "snapped up successfully Please pay as soon as possible ") except: print (f" try to submit the order again ") time.sleep (0.01) if _ _ name__ = ='_ main__': login () Picking (0); buy ("2021-05-12 21 python 57 python 08.211142"); # modify it to your own time, pay attention to the time format must be on "how to use selenium to achieve Taobao just-in-time kill order" this article is introduced here, thank you for reading! I believe that everyone has a certain understanding of "how python uses selenium to achieve Taobao on-time kill and grab order" knowledge. If you still want to learn more knowledge, you are welcome to follow the industry information channel.

Tags: Taobao orders on time time login success buttons browsers knowledge browsing settlement content articles shopping cart shopping same operating system code value again Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Microsoft Shulou Technology MariaDB Docker