zoukankan      html  css  js  c++  java
  • 批量从excel文件中传输数据

    批量从excel文件中传输数据:

    import openpyxl
    import hashlib
    import requests
    import json
    import time
    wb = openpyxl.load_workbook('pass_che.xlsx')
    
    # 获取workbook中所有的表格
    sheets = wb.sheetnames
    
    def main(city, phone,time=time.time()):
        time = str(time).split('.')[0]
        token = 'yyyyyy'    # 标识接口认证 
        data = {
            'name': '先生',
            'mobile': phone,
            'city': city,
            'brand': '未知',
            'series': '未知',
            'model': '未知',
            'kilometer': '10',
            'licensed_date_year': '2010 3',
            'is_operation': '',
            'is_accidented': ''
        }
        data = json.dumps(data)
        # print(data)
    
        sign = hashlib.md5((data + token + time).encode("utf-8")).hexdigest()
        post_data = {
            'token': token,
            'sign': sign,
            'time': time,
            'data': data,
        }
        url = 'xxxx'  # 公司机密
        r = requests.post(url, data=post_data)
        print(r.text)
        print('查入成功')
    
    # 循环遍历所有sheet
    for i in range(len(sheets)):
        sheet = wb[sheets[i]]
    
        for r in range(1, sheet.max_row + 1):
            if r == 1:
                city = str(sheet.cell(row=r, column=1).value)
                phone = str(sheet.cell(row=r, column=2).value)
                print(city,phone)
                main(city,phone)
            else:
                city = str(sheet.cell(row=r, column=1).value)
                phone = str(sheet.cell(row=r, column=2).value)
                print(city,phone)
                main(city,phone)
    
  • 相关阅读:
    kali 所有版本
    kali有关问题及kali2018.2安装
    python2
    burpsuite 破解教程
    python生成个性二维码
    万能密码
    python 1
    python
    python 第三方库安装
    Androidstdio 简单界面设计 登陆系统
  • 原文地址:https://www.cnblogs.com/shaozheng/p/12802887.html
Copyright © 2011-2022 走看看