• py propterties reuqest.post


    import traceback


    class Properties(object):

    def __init__(self, fileName):
    self.fileName = fileName
    self.properties = {}

    def __getDict(self, strName, dictName, value):

    if(strName.find('.') > 0):
    k = strName.split('.')[0]
    dictName.setdefault(k, {})
    return self.__getDict(strName[len(k) + 1:], dictName[k], value)
    else:
    dictName[strName] = value
    return

    def getProperties(self):
    pro_file = open(self.fileName, 'Ur', encoding='utf-8')
    for line in pro_file.readlines():
    line = line.strip().replace(' ', '')
    if line.find("#") != -1:
    line = line[0:line.find('#')]
    if line.find('=') > 0:
    strs = line.split('=')
    strs[1] = line[len(strs[0]) + 1:]
    self.__getDict(strs[0].strip(),
    self.properties, strs[1].strip())
    return self.properties
     
    =============
     
     
    import os

    os.system("testAccountGrant.1.py")
    os.system("testApointmentSubmit.1.py")
    os.system("testMedicalMealDetail.1.py")
    os.system("testNbYbtYYXinxi.1.py")
    os.system("testQueryTbDicTjdcList.1.py")
    os.system("testQueryTbDicTjxmList.1.py")

    os.system("testGetPublicpharmacy.1.py")

    os.system("pause")
    ===============
    import os
    import requests
    import json
    from Util import Properties


    print('########[agreementSign]################ * start')

    properties = Properties("./global.properties").getProperties()

    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
    'Accept': 'text/html;q=0.9,*/*;q=0.8,application/json, text/plain, */*',
    # 'Accept': 'text/html;q=0.9,*/*;q=0.8',
    'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
    'Accept-Encoding': 'gzip',
    'Connection': 'close',
    # 'content-type': 'application/json;charset=utf-8',
    'Referer': None # 注意如果依然不能抓取的话,这里可以设置抓取网站的host
    }


    def data1():
    with open('./json/addRenewalInfo.1.json', encoding='utf-8') as json_file:
    data = json.load(json_file)
    return data


    print("***执行接口>>>>>", properties['addRenewalInfo'], ' 【请求参数】', data1())

    files = {'imgSign': ('1.jpg', open(
    'C:\Users\Administrator\Desktop\imgs\2.jpg', 'rb'), 'image/jpg'), 'xxx': ('1.jpg', open(
    'C:\Users\Administrator\Desktop\imgs\3.jpg', 'rb'), 'image/jpg')}


    r1 = requests.post(properties['addRenewalInfo'],
    data=data1(), files=files, headers=headers)
    r1.encoding = 'utf-8'
    print('【响应】', r1.text)

    昨日已逝正在输入···
    赞赏支持!!!
    分享到: 更多
  • 相关阅读:
    广度优先搜索-八数码问题
    广度优先搜索-鸣人和佐助
    广度优先搜索-迷宫问题
    广度优先搜索-抓住那头牛
    Unity面试题汇总(第一部分)
    独立项目-Socket通讯 应用/客户端和服务器的简单通讯-04
    独立项目-Socket通讯 服务器端代码-04
    独立项目-Socket通讯 客户端代码-03
    独立项目-Socket通讯 发送数据包和接收数据包过程图-02
    独立项目-Socket通讯 服务器端架构图-01
  • 原文地址:https://www.cnblogs.com/rhxuza1993/p/9239501.html
Copyright © 2020-2023  润新知