71 lines
2.7 KiB
Python
71 lines
2.7 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
|
|
|
|
#获取会员卡基础信息
|
|
name = '15888265981'
|
|
password = 'Ff123456'
|
|
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(executable_path=r"C:\Users\admin\Desktop\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(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"C:\Users\admin\Desktop\新建XLS 工作表.xls")
|
|
table = data.sheet_by_index(0) # 通过索引顺序获取
|
|
h = table.nrows
|
|
l = table.ncols
|
|
print(u"表数据的行数为%s,列数为%s"%(h,l))
|
|
time.sleep(0.2)
|
|
for i in range(1,h):
|
|
try:
|
|
hettps1 = 'https://yunxiu.f6car.cn/cayenne/view/index.html#/index/home'
|
|
https='https://yunxiu.f6car.cn/cayenne/view/index.html#/cayenne-member/customer/list' #进入客户信息页面
|
|
driver.get(https)
|
|
idMember =table.cell(i, 0).value #按行读取数据
|
|
#传值转换
|
|
#driver.switch_to.frame('weixin-page-iframe')
|
|
time.sleep(0.5)
|
|
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="app"]/div/div/div/div[2]/div/div[1]/div[1]/div/input').send_keys(idMember) #输入手机号
|
|
time.sleep(1)
|
|
driver.find_element_by_xpath(
|
|
'//*[@id="app"]/div/div/div/div[2]/div/div[1]/div[1]/div/div/button').click() #点击搜索
|
|
time.sleep(2)
|
|
input1 = driver.find_element_by_xpath('//*[@id="app"]/div/div/div/div[2]/div/div[3]/div[1]/div[3]/table/tbody/tr/td[2]/div/div/span').text
|
|
input2 = driver.find_element_by_xpath('//*[@id="app"]/div/div/div/div[2]/div/div[3]/div[1]/div[3]/table/tbody/tr/td[4]/div').text
|
|
print(i,'@', idMember,'@',input1,'@',input2 )
|
|
except:
|
|
print('失败')
|
|
continue |