In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to implement the panic buying script in Python. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Python script implementation
Install Python. I installed anaconda.
Install the webdriver extension. It is part of the Selenium module. Selenium is a tool for testing Web applications to see if your applications work well on different browsers and operating systems. The Selenium test runs directly in the browser, just like a real user is working on it. So you just install Selenium:Win+R, type cmd, and type pip show selenium on the command line.
Install chrome browser (because I am using Google)
Install chromedriver. It is a plug-in for chrome, so that webDriver can control the automatic operation of chrome browser by operating chromedriver, such as opening a web page, clicking a button and so on.
Download address:
Http://chromedriver.storage.googleapis.com/index.html or https://npm.taobao.org/mirrors/chromedriver/
* * Note: the corresponding chromedriver version should be selected according to the computer system and chrome browser version when downloading. * * you can view your chrome version through the three-point → in the upper right corner of the browser to help → about Google Chrome.
After downloading the chromedriver installation package, extract it and place it in the same directory as the chrome installation, and add the path to the environment variable PATH.
Then verify that the installation is successful with the following code:
Ran Goose, I encountered a mistake at this time, as follows
So I put chromedriver.exe in my python script folder and solved the problem perfectly!
[supplement] I know why I made the above error, because the path was not entered! Enter your own downloaded chromedriver installation path at the red box shown in the following figure to run successfully.
The complete Python script code is as follows:
````python# coding=utf-8import osfrom selenium import webdriverimport datetimeimport timefrom os import path# here change the chromedriver to the path to download the extracted chromedriver driver = webdriver.Chrome ("E:/JupyterNotebookSavePath/chromedriver") # driver.maximize_window () def login (): # Open the home page of Taobao, and scan the code to log in to Taobao driver.get ("https://www.taobao.com") time.sleep (3) if driver.find_element_by_link_text (" pro ") Please log in "): driver.find_element_by_link_text (" dear " Please log in. Click () print ("scan the code in 15 seconds") time.sleep (15) # Open the front page of the shopping cart list driver.get ("https://cart.taobao.com/cart.htm") time.sleep (3) # fully selected shopping cart if driver.find_element_by_id (" J_SelectAll1 "): driver Find _ element_by_id ("J_SelectAll1") .click () now = datetime.datetime.now () print ("login success:" Now.strftime ("% Y-%m-%d% H:%M:%S") def buy (times): while True: # record the current time Use the datatime built-in module now = datetime.datetime.now () .strftime ("% Y-%m-%d% H:%M:%S") print (times) print (now) # comparison time If the time is up, click settlement if now = = times: try: if driver.find_element_by_id ("J_Go"): driver.find_element_by_id ("J_Go"). Click () driver.find_element_by_link_text ('submit order'). Click () Print ('snapped up successfully Please pay as soon as possible') except: print ('Please try to submit the order again') print (now) time.sleep (0.1) if _ _ name__ = "_ _ main__": times = input ("Please enter the rush time (for example, format: 2021-02-01 00:00:00):") login () buy (times) about " This is the end of the article on how to implement snap-up scripts in Python. Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.