118 lines
5.1 KiB
Python
118 lines
5.1 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
|
|
from selenium.webdriver import Chrome
|
|
from selenium.webdriver.chrome.service import Service
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
|
|
#获取会员卡基础信息
|
|
name = '15596363210'
|
|
password = 'Aa123456'
|
|
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)
|
|
chrom_dirverpath = "D:\ProgramTools\chromedriver-win64\chromedriver.exe"
|
|
# chrome_options = Options()
|
|
# chrome_options.add_argument("--headless")
|
|
service = Service(executable_path=f'{chrom_dirverpath}')
|
|
driver = Chrome(service=service)
|
|
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()
|
|
# 多店模式需要下面一行代码
|
|
# WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//*[@id="app"]/div[2]/div[1]/div[1]/div[2]/div/div/div[2]/div[2]/div/div[1]/div/div[6]/p[1]'))).click()
|
|
WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "/html/body/div[3]/div/div[1]/button"))).click()
|
|
WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.XPATH, '//*[@id="subMain"]/div/div[3]/div[1]/div[1]/div/span[2]'))).click()
|
|
# 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(15)#预设时间
|
|
|
|
# 新建一个excel文件
|
|
file = xlwt.Workbook() # 注意这里的Workbook首字母是大写,无语吧
|
|
# 新建sheet
|
|
table = file.add_sheet('sheet name', cell_overwrite_ok=True)
|
|
if 1==1:
|
|
he = 0
|
|
hen = 0
|
|
heng = 0
|
|
hang = 0
|
|
len = 0
|
|
#获取所有内容
|
|
#打开excel文件
|
|
data = xlrd.open_workbook(r'D:\Idea Project\F6+宜搭+其它(1)\new\文件输出\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(0,h):
|
|
try:
|
|
starttime = datetime.datetime.now()
|
|
idMember =table.cell(i, 0).value #按行读取数据
|
|
receiveAmount = table.cell(i, 1).value # 按行读取数据
|
|
https='https://yunxiu.f6car.cn/kzf6/consumeBill/index.do?page=view/index.html%23/memberCard/tkdAdd&cardId='+idMember
|
|
#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.5)
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="app"]/div[2]/div[2]/div/section[2]/div[2]/div[2]/div[1]/div/div/input').send_keys(receiveAmount)
|
|
#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.5)
|
|
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="app"]/div[2]/div[2]/div/section[2]/div[2]/div[2]/div[3]/div/div[1]/input').click()
|
|
time.sleep(0.5)
|
|
driver.find_element_by_xpath('/html/body/div[3]/div[3]/div[1]/ul/li[9]/span').click()
|
|
time.sleep(0.5)
|
|
# 进入结算
|
|
''
|
|
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/section[3]/div/button[1]/span').click()
|
|
time.sleep(1)
|
|
try:
|
|
driver.find_element_by_xpath('/html/body/div[3]/div/div[3]/button[1]/span').click()
|
|
time.sleep(0.5)
|
|
except:
|
|
len = 1
|
|
# 第四次切换
|
|
#driver.switch_to.frame('weixin-page-iframe')
|
|
time.sleep(0.5)
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="app"]/div/div/div/div/div/div[2]/div[2]/div[2]/div[1]/div[1]/div/div/div/div[2]/div').click()
|
|
time.sleep(0.5)
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="app"]/div/div/div/div/div/div[3]/div/div/button[1]/span').click()
|
|
time.sleep(0.5)
|
|
endtime = datetime.datetime.now()
|
|
implement = (endtime - starttime).seconds
|
|
print(i,idMember, implement )
|
|
except:
|
|
print('失败')
|
|
continue |