84 lines
3.4 KiB
Python
84 lines
3.4 KiB
Python
# -*- coding:UTF-8 -*-
|
|
# 功能:F6系统页面会员卡退卡操作
|
|
from selenium import webdriver
|
|
from selenium.webdriver.support.ui import Select
|
|
from selenium.webdriver import ActionChains
|
|
import time
|
|
import xlrd
|
|
import xlwt
|
|
import re
|
|
from xlutils.copy import copy
|
|
from selenium.webdriver.common.keys import Keys
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
import datetime
|
|
|
|
# 获取会员卡基础信息
|
|
name = '15651006300'
|
|
password = 'Wamh523364'
|
|
option_chrome = webdriver.ChromeOptions()
|
|
option_chrome.add_argument('--headless')
|
|
|
|
http = 'https://m.f6car.cn/'
|
|
# 进入链接获取json
|
|
# driver = webdriver.Chrome(chrome_options=option_chrome)
|
|
#driver = webdriver.Chrome(chrome_options=option_chrome)
|
|
driver = webdriver.Chrome(executable_path=r"C:\迅雷下载\python 暂存文件\Python\chromedriver.exe")
|
|
driver.maximize_window()
|
|
driver.implicitly_wait(2)
|
|
driver.get(http)
|
|
driver.find_element_by_xpath('//*[@id="pane-username"]/form/div[1]/div/div/input').send_keys(name)
|
|
driver.find_element_by_xpath('//*[@id="pane-username"]/form/div[2]/div/div[1]/input').send_keys(password)
|
|
driver.find_element_by_xpath('//*[@id="pane-username"]/form/div[3]/div/button/span').click()
|
|
time.sleep(10) # 预设时间
|
|
|
|
# 新建一个excel文件
|
|
file = xlwt.Workbook() # 注意这里的Workbook首字母是大写,无语吧
|
|
# 新建sheet
|
|
table = file.add_sheet('sheet name', cell_overwrite_ok=True)
|
|
# 获取所有内容
|
|
# 打开excel文件
|
|
data = xlrd.open_workbook(r'C:\Users\admin\Desktop\Python脚本\图形界面自动化脚本\F6系统常用脚本\Excel通用存储位置.xls')
|
|
print(data)
|
|
table = data.sheet_by_index(0) # 通过索引顺序获取
|
|
h = table.nrows
|
|
l = table.ncols
|
|
print(u"表数据的行数为%s,列数为%s" % (h, l))
|
|
|
|
# 获取卡项目
|
|
for i in range(1, h):
|
|
try:
|
|
starttime = datetime.datetime.now()
|
|
https = 'https://yunxiu.f6car.cn/kzf6/contactBook/contactBookList.do?page=view/index.html%23/'
|
|
# http = 'https://yunxiu-trial.f6car.cn/kzf6/payment/toGathering.do?idSourceBill=' + idMember + '&billType=TKD'
|
|
# 进入链接获取json
|
|
driver.get(https)
|
|
# 传值转换
|
|
driver.switch_to.frame('weixin-page-iframe')
|
|
time.sleep(0.2)
|
|
idMember = table.cell(i, 0).value # 按行读取数据
|
|
input_box = driver.find_element_by_xpath('//*[@id="pane-1"]/div/div[2]/div[1]/div[1]/div/input')
|
|
input_box.send_keys(Keys.CONTROL, 'a')
|
|
input_box.send_keys(Keys.BACK_SPACE)
|
|
time.sleep(0.3)
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="pane-1"]/div/div[2]/div[1]/div[1]/div/input').send_keys(idMember)
|
|
# driver.find_element_by_xpath(
|
|
# '//*[@id="app"]/div[2]/div[2]/div/section[2]/div[2]/div[2]/div[3]/div/div/input').send_keys(onename)
|
|
# 通过父类进行定位
|
|
time.sleep(0.3)
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="pane-1"]/div/div[2]/div[1]/div[1]/div/div/button/i').click() # 点击查询
|
|
time.sleep(0.2)
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="pane-1"]/div/div[2]/div[3]/div/div[1]/div[3]/table/tbody/tr/td[8]/div/button[3]/span').click() # 离职
|
|
time.sleep(0.2)
|
|
driver.find_element_by_xpath('/html/body/div[4]/div/div[3]/button[1]/span').click() # 离职
|
|
time.sleep(0.2)
|
|
# 进入结算
|
|
endtime = datetime.datetime.now()
|
|
implement = (endtime - starttime).seconds
|
|
print(i, idMember,implement)
|
|
|
|
except:
|
|
print('失败')
|
|
continue |