美文网首页
读取excel+发送请求

读取excel+发送请求

作者: Mracale | 来源:发表于2021-01-21 13:13 被阅读0次
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

# -*- coding:utf-8 -*-

import xlrd
import requests
import time
def __bytes__(self):
    return str(self).encode('utf-8')


def hello(rows) :
    headers = {'content-type': "application/json","Authorization":"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOjY4LCJzdWIiOiIyMDAwMTEiLCJpc3MiOiIwOThmNmJjZDQ2MjFkMzczY2FkZTRlODMyNjI3YjRmNiIsImlhdCI6MTYxMTE5Njc0OSwiYXVkIjoicmVzdGFwaXVzZXIiLCJleHAiOjE2MTEyMTgzNDksIm5iZiI6MTYxMTE5Njc0OX0.n99ciA_49N7uBkOUswekmAdAEcLbg9VjQ8NCAbfWMBY"}
    url = "http://www.shengjie.club/api/customer/add"
    data = '{"address": "'+rows[5]+'","city": "'+rows[3]+'","country": "中国","customerLevel": "中","fullName": "'+rows[0]+'","industry": "其他","legalRepresentative": "'+rows[1]+'","organizationCode": "'+rows[4]+'","province": "'+rows[2]+'"}'
    data = data.encode('utf-8')
    res = requests.post(url=url,data=data,headers=headers)
    print(res.text)


x1 = xlrd.open_workbook("./888.xls")

# 2、获取sheet对象
# print(x1.sheet_names())
sheet = x1.sheet_by_index(0) # sheet索引从0开始

# print (sheet.name,sheet.nrows,sheet.ncols)
n = sheet.nrows
while n > 1:
    n -= 1
    rows = sheet.row_values(n) # 获取每一行内容
    # print(rows[0],rows[1],rows[2],rows[3],rows[4],rows[5])
    hello(rows)
    time.sleep( 5 )
print('循环结束。')

相关文章

  • 读取excel+发送请求

  • 爬虫的主要内容

    爬虫的主要内容 requests 发送请求 传递url参数 读取相应内容 定制请求头部 Post请求 响应状态码 ...

  • 15.服务器

    服务器 1. 命令请求的执行过程 1.1 发送命令请求 下图是客户端接收并发送命令请求的过程。 1.2 读取命令请...

  • python spider cookie

    1、第一次发送POST请求,获取响应头Cookie值,保存到本地 2、第二次后续都发送GET请求,直接读取本地保存...

  • redis 服务器

    一个命令请求从发送到完成主要包括以下步骤:1、客户端将命令请求发送给服务器。2、服务器读取命令请求,并分析出命令参...

  • 以太坊源码阅读-网络处理-RPC

    server.go 实现了RPC服务端的核心逻辑,包括注册、读取请求、处理请求、发送回应等逻辑。// Server...

  • IE11中相同的get请求会返回相同的值

    IE11中相同的get请求多次发送时,会直接读取本地的缓存,但是F12打开调试又会重新向服务器发送请求。简单的解决...

  • [PHP] js,php的url编码

    js发送ajax请求,将文本内容使用encodeURIComponent进行编码。php读取字段的时候,会自动对文...

  • spring boot 工程乱码问题

    1、配置html页面,读取templates中文件时,出现乱码 直接发送get请求可以看到Content-Type...

  • 使用requests发送请求-01

    发送get请求 发送post请求 上传文件 携带cookie发送请求 使用session发送请求

网友评论

      本文标题:读取excel+发送请求

      本文链接:https://www.haomeiwen.com/subject/azgrzktx.html