from selenium import webdriver
from time import sleep
import datetime
import os
import shutil
import datetime
#获取当前时间并参数化
now_time = datetime.datetime.now()
chage_time = (now_time + datetime.timedelta(days=-1)).strftime('%Y-%m-%d')
#删除前一天的数据
shutil.move("C:/Users/Administrator/Downloads/XXXX.xls","D:/Python/python/XXXX"+chage_time+".x
import datetime
#获取当前时间并参数化
now_time = datetime.datetime.now()
chage_time = (now_time + datetime.timedelta(days=-1)).strftime('%Y-%m-%d')
#删除前一天的数据
shutil.move("C:/Users/Administrator/Downloads/XXXX.xls","D:/Python/python/XXXX"+chage_time+".xls")
shutil.move("C:/Users/Administrator/Downloads/XXX.xls","D:/Python/python/XXX"+chage_time+".xls")
#驱动位置
chrome_driver = 'D:/Python/python/ng/chromedriver.exe'
driver = webdriver.Chrome(executable_path=chrome_driver)
#打开网址一直操作到下载文件为止
driver.get("http://10.10.10.10/portal")
sleep(2)
driver.find_element_by_name("username").clear()
driver.find_element_by_name("username").send_keys("jx.ngsh")
driver.find_element_by_name("password").clear()
driver.find_element_by_name("password").send_keys("jxng*123")
driver.find_element_by_class_name('login_form_submit').click()
sleep(5)
driver.find_element_by_id('menugroup_inner_2378').click()
sleep(2)
driver.find_element_by_id('menu_inner_1164').click()
driver.get('http://10.10.10.10/zmng/trueCodeAnalysis?result=login<PAToken=amlhbmd4aS5uZ3NoKjhhODE4MDg2NDEyNjM3ZTUwMTQyZmE2YjdkOGEwNTcwKjM1MzIqU3RyaW5n')
driver.find_element_by_xpath('//*[@id="beginDate"]').click()
js = "$('input[id=id]').attr('readonly','')"
driver.execute_script(js)
driver.execute_script("document.getElementById('beginDate').value='2020-01-01';")
sleep(5)
driver.find_element_by_xpath('//*[@id="tableGray"]/tbody/tr[4]/td[2]/select/option[3]').click()
sleep(5)
driver.find_element_by_class_name('ui-button-text').click()
sleep(5)
driver.find_element_by_xpath('//*[@id="exportExcel"]/span[2]').click()
sleep(10)
driver.find_element_by_xpath('//*[@id="exportCodeExcel"]/span[2]').click()
sleep(100)
#退出系统
driver.quit()
本文链接:https://my.lmcjl.com/post/4373.html
4 评论