Files
F6--/F6系统常用脚本/修改套餐卡有效期为永久.py
2026-01-30 11:28:35 +08:00

83 lines
3.4 KiB
Python

# -*- coding:UTF-8 -*-
#修改套餐卡-永久有效-按表格中的有效期进行处理
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
import os
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import pandas as pd
#获取基础信息
name = '16621142776'
password = 'f6wuyanzu'
option_chrome = webdriver.ChromeOptions()
option_chrome.add_argument('--headless')
http='https://m.f6car.cn/'
#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)
# 在输入框中输入账号和密码
username = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, r'//*[@id="pane-username"]/form/div[1]/div/div[1]/input')))
enter = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, r'//*[@id="pane-username"]/form/div[3]/div/button')))
username.clear()
username.send_keys(name)
driver.find_element_by_xpath(r'//*[@id="pane-username"]/form/div[2]/div/div[1]/input').send_keys(password)
enter.click()
time.sleep(15)#预设时间
file = xlwt.Workbook()
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:
idMember =table.cell(i, 0).value #id
#idMember1 =table.cell(i, 1).value #日期
'''
httpas='https://yunxiu.f6car.cn/cayenne/view/index.html#/cayenne-promotion/marketing/vipList'
driver.get(httpas)
time.sleep(0.5)
try:
driver.find_element_by_xpath('/html/body/div/div/div[3]/button[1]').click()
time.sleep(0.5)
except:
a = 1
'''
https='https://yunxiu.f6car.cn/kzf6/macan/index.do?page=/view/index.html%23/macan-view/cardManage/cardEdit/'+idMember #进入页面
driver.get(https)
time.sleep(0.3)
#传值转换
driver.switch_to.frame('weixin-page-iframe')
driver.find_element_by_xpath(
'//*[@id="app"]/div[2]/div/div/div[2]/div[1]/div/div/div[1]/div[6]/form/div[2]/div[1]/div/div/div').click() #点击可以门店
time.sleep(0.3)
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div/div/div[2]/div[1]/div/div/div[2]/div/div[2]/div/div[2]/table/thead/tr/th[1]/div/label/span/span').click()
time.sleep(0.3)
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div/div/div[2]/div[1]/div/div/div[2]/div/div[3]/span/button[1]/span').click()
time.sleep(0.3)
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div/div/div[2]/div[2]/div/button[1]/span').click()
time.sleep(0.2)
endtime = datetime.datetime.now()
print(i,'@', idMember)
except:
print('失败')
continue