96 lines
4.5 KiB
Python
96 lines
4.5 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
|
|
import datetime
|
|
from xlutils.copy import copy
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
|
# 获取会员卡基础信息
|
|
name = '15888265981'
|
|
password = 'F6123456'
|
|
zhi = 1
|
|
option_chrome = webdriver.ChromeOptions()
|
|
option_chrome.add_argument('--headless')
|
|
for hum in range(zhi):
|
|
# http='https://yunxiu-trial.f6car.cn/member/customer/list?pageSize=5000&pageNo=1'
|
|
httptx = 'https://yunxiu.f6car.cn'
|
|
# 初步加载处理
|
|
# chrom_opt = webdriver.ChromeOptions()
|
|
# prefs = { "profile.managed_default_content_settings.images": 2 }
|
|
# chrom_opt.add_experimental_option("prefs", prefs)
|
|
# driver = webdriver.Chrome(executable_path="E:/Python/chromedriver.exe", chrome_options=chrom_opt)
|
|
# 无显示预处理
|
|
# option=webdriver.ChromeOptions()
|
|
# option.add_argument('headless') # 设置option
|
|
# driver = webdriver.Chrome(chrome_options=option)
|
|
# 进入链接获取json
|
|
# driver = webdriver.Chrome(chrome_options=option_chrome)
|
|
driver = webdriver.Chrome(executable_path=r"C:\迅雷下载\python 暂存文件\Python\chromedriver.exe")
|
|
driver.maximize_window()
|
|
driver.implicitly_wait(0.1)
|
|
|
|
driver.get(httptx)
|
|
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) # 预设时间
|
|
print("登陆系统")
|
|
print("创建文件")
|
|
# 新建一个excel文件
|
|
file = xlwt.Workbook() # 注意这里的Workbook首字母是大写,无语吧
|
|
# 新建sheet
|
|
table = file.add_sheet('sheet name', cell_overwrite_ok=True)
|
|
|
|
# 打开excel文件
|
|
print("打开文件")
|
|
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))
|
|
https = 'https://yunxiu.f6car.cn/kzf6/partInfo/newPageList.do?page=view%2Fmaterial.html%23/info/list/cloud'
|
|
driver.get(https)
|
|
# 传值转换
|
|
driver.switch_to.frame('weixin-page-iframe')
|
|
# 获取卡项目
|
|
num = 0
|
|
for i in range(0, h): # 浮点型
|
|
try:
|
|
|
|
d1 = datetime.datetime.now()
|
|
receiveAmount1 = table.cell(num, 0).value # 按行读取数据
|
|
receiveAmount2 = table.cell(num, 1).value # 按行读取数据
|
|
# https='https://yunxiu-trial.f6car.cn/kzf6/member/index.do?page=/view/index.html%23/customer/detail/'+idMember
|
|
# 进入链接获取json
|
|
num = num + 1
|
|
|
|
time.sleep(0.1)
|
|
input_box = driver.find_element_by_xpath('/html/body/div/div/div/div/div/div/div/div/div[2]/div/div[3]/input')
|
|
input_box.send_keys(Keys.CONTROL, 'a')
|
|
input_box.send_keys(Keys.BACK_SPACE)
|
|
# input_box.send_keys(Keys.CONTROL, 'v')
|
|
driver.find_element_by_xpath('/html/body/div/div/div/div/div/div/div/div/div[2]/div/div[3]/input').send_keys(
|
|
receiveAmount1)
|
|
|
|
time.sleep(0.1)
|
|
driver.find_element_by_xpath('/html/body/div/div/div/div/div/div/div/div/div[2]/div/div[3]/div/button/i').click()
|
|
time.sleep(0.1)
|
|
input1 = driver.find_element_by_xpath('//*[@id="cloudTable"]/div/div/table/tbody/tr[1]/td[2]/div')
|
|
input2 = driver.find_element_by_xpath('//*[@id="cloudTable"]/div/div/table/tbody/tr[1]/td[3]/div')
|
|
input3 = driver.find_element_by_xpath('//*[@id="cloudTable"]/div/div/table/tbody/tr[1]/td[5]/div')
|
|
input4 = driver.find_element_by_xpath('//*[@id="cloudTable"]/div/div/table/tbody/tr[1]/td[6]/div')
|
|
input6 = driver.find_element_by_xpath('//*[@id="cloudTable"]/div/div/table/tbody/tr[1]/td[7]/div')
|
|
|
|
input5 = driver.find_element_by_xpath('//*[@id="cloudTable"]/div[2]/span')
|
|
d3 = d1 + datetime.timedelta(hours=10)
|
|
print(num, '@',receiveAmount1,'@', receiveAmount2,'@', input1.text, '@', input2.text, '@', input3.text, '@', input4.text, '@', input6.text, '@', input5.text, '@',d1)
|
|
except:
|
|
print(num,receiveAmount1,':未识别到内容',d1) |