https://www.jb51.net/article/105050.htm

 

from requests import request
import unittest
from Common.HandleConfig import conf
import urllib3
import os

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


class DownLoadCategoryAttributeTemplate(unittest.TestCase):
    """类目属性模板-下载"""

    def test_downLoadCategoryAttributeTemplate(self):
        url = conf.get("product_url", "test") + "/productManage/categoryAttribute/exportCategoryAttributeTemplate"
        print(url)
        headers = {"Content-Type": "application/json", "authtype": "oidc",
                   "authorization": conf.get("product_url", "authorization")}
        response = request(method="get", url=url, headers=headers, verify=False)
        print(response)
        print(response.status_code)
        # 返回值为字节流,所以要加b,w表示文件以可写模式打开
        with open("下载模板.xlsx", "wb") as f:
            f.write(response.content)
        # 校验文件是否存在
        assert os.path.exists("下载模板.xlsx")

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
  • 2021-11-23
  • 2021-05-19
  • 2021-07-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2021-06-29
  • 2022-12-23
  • 2021-12-22
  • 2021-07-11
相关资源
相似解决方案