doAdd.py 1.88 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import requests
import json
import urllib3
from commons import common as com
from commons.api.login import login
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
ll=login()

class doAdd():
    
    url="http://test.trace.diligrp.com:8393/newRegisterBill/doAdd.action"
    header={
            "Host": "test.trace.diligrp.com",
            "Connection": "keep-alive",
            "Content-Length": "325",
            "Accept": "application/json,text/javascript,*/*;q=0.01",
            "User-Agent": "Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.212Safari/537.36",
            "Content-Type": "application/json",
            "Origin": "http://test.trace.diligrp.com:8393",
            "Referer": "http://test.trace.diligrp.com:8393/newRegisterBill/add.html",
            "Accept-Encoding": "gzip,deflate",
            "Accept-Language": "zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7"}
    body={"registerHeadWeight":"0","registerHeadRemainWeight":"0","imageCertList":[],"measureType":20,"registType":10,"userId":516,"arrivalTallynos":[],"arrivalDatetime":"","truckType":10,"weight":"111","weightUnit":1,"productName":"大白菜","productId":2190,"originName":"","originId":"","unitPrice":"","truckTareWeight":"","remark":"","specName":"","brandName":"","plate":"川A123456"}
    
    
    def __init__(self):
        self.url=doAdd.url.replace("http://test.",com.get_global_config("global_data", "environment", "en") )
        self.header=doAdd.header
        self.body=doAdd.body

    def post(self,account,**kwargs):
        #解决不同接口对于不同用户的场景
        se=ll.get_session(account)
        re=se.post(**kwargs)
        ll.close_session()
        return re




# tt=doAdd()
# re=tt.post("user01",url=tt.url,headers=tt.header,json=tt.body,proxies={'http': 'http://localhost:8888'})
# print(re.json())