Get the App
SLTechnology News&Howtos  ›  Development  › 

How to clock in Mini Program regularly through Python

Shulou Source: shulou.com Published: 2022-06-01 09:43:11 11月17日 Update

This article mainly shows you "how to clock in regularly through Python", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn how to clock in Mini Program regularly through Python "this article.

Just create any folder under your python project (daka in the following figure), and then download chromedriver.exe, ask_for_leave.py, log.txt (this folder is empty, save the log information when running the program, and create a folder called log.txt directly under the folder).

Chromedriver.exe

This file is the driver file of the google browser. You can select the same version of the driver as the google browser on your computer at the download address.

How to view the google browser version

Step 1: open the Chrome browser

Step 2: click the three points in the upper right corner and select "Settings"

Step 3: click "about Chrome"

Step 4: get the Chrome version number

Ask_for_leave.py (only need to change two places of dimension modification)

From selenium import webdriverfrom time import sleepfrom selenium.webdriver.common.keys import Keysimport datetimefrom selenium.webdriver.support.wait import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.select import Selectfrom selenium.webdriver.chrome.options import Optionsdef qinjia (browser,url): browser.get (url) sleep (1) browser.implicitly_wait (3) WebDriverWait (browser,5). EC.presence_of_all_elements_located ((By.ID) "user_main")) user_main_div=browser.find_element_by_id ("user_main") username_input=user_main_div.find_element_by_id ("txtId") # username password_input=user_main_div.find_element_by_id ("txtMM") # password login_btn=user_main_div.find_element_by_id ("IbtnEnter") # login button # modify 1: account and password here username_input.send_keys ("= account =") password_input.send_keys ("= password =") login_btn.click () sleep (1) browser.implicitly_wait (3) WebDriverWait (browser 5) .clients (EC.presence_of_all_elements_located ((By.CLASS_NAME) "tabThinM")) table_tag=browser.find_element_by_class_name ("tabThinM") href_body=table_tag.find_elements_by_tag_name ("tbody") [2] href=href_body.find_elements_by_tag_name ("tr") [1] .find _ element_by_tag_name ("a") .get_attribute ("href") browser.get (href) table_wjTA=browser.find_element_by_id ("wjTA") div_gerenjiankang=table_wjTA.find_elements_by_class_name ("dvO") [0] # personal Health div_shenqing=table_wjTA.find_elements_by_class_name ("dvO") [1] # Application for admission to # personal Health selects_tag=div_gerenjiankang.find_elements_by_tag_name ("select") work_station_select=selects_tag [2] health_station_select=selects_ Tag [3] live_station_select=selects_tag [4] family_station_select=selects_tag [5] Select (work_station_select). Select_by_value ("1") Select (health_station_select). Select_by_value ("1") Select (live_station_select). Select_by_value ("1") Select (family_station_select). Select_by_value ("1") # apply for entry Select_shenqin_time_tags=div_shenqing.find_elements_by_tag_name ("select") input_shenqin_reaseons_tags=div_shenqing.find_elements_by_tag_name ("input") target_place_input=input_shenqin_reaseons_tags [0] reason_input=input_shenqin_reaseons_tags [1] # modify 2: make the application destination and subject matter here target_place_input.send_keys ("= purpose of application = ") reason_input.send_keys (" = = subject = = ") Select (select_shenqin_time_tags [0]). Select_by_value (" 1 ") Select (select_shenqin_time_tags [1]). Select_by_value (" 06 ") Select (select_shenqin_time_tags [2]). Select_by_value (" 3 ") Select (select_shenqin_time_tags [3]). Select_by_value (" 23 ") submit_input=browser.find_element_by_tag_name (" input ") submit_input.click () def log (message): curent_time = datetime.datetime.now () print (curent_time) f = open (" log.txt " "a +", encoding= "utf-8") f.write (str (curent_time) + ":" + message+ "\ n") f.close () def headLessChrome (): chrome_driver = r "chromedriver.exe" chrome_options=Options () chrome_options.add_argument ("- headless") chrome_options.add_argument ("- disable-gpu") browser=webdriver.Chrome (options=chrome_options Executable_path=chrome_driver) return browserif _ _ name__ ='_ _ main__': url= "http://login.cuit.edu.cn/Login/xLogin/Login.asp" browser=headLessChrome () try: qinjia (browser,url) log (" success ") except: log (" failure ") browser.quit ()

Log.txt

Create an empty log.txt file directly.

Once created, run the ask_for_leave.py file and run it once.

The above is all the contents of the article "how to clock in Mini Program regularly through Python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: File program folder browser browse sign in content password version article health personal subject matter just purpose account study help run drive Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux OPPO Reno vpn Shulou Information