1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| from loguru import logger import requests
class KColor(): Red = 255 Green = 65280 Blue = 16711680 Yellow = 65535 White = 16777215 Pink = 12434430 class KdocsApi: def __init__(self,token,url): self.url = url self.headers = { 'AirScript-Token': token, 'Content-Type': 'application/json' }
def run_script(self, func, param,sheet_name): json_data = { 'Context': { 'argv': { 'param': param, 'func': func }, 'sheet_name': sheet_name }, } response = requests.post(self.url, headers=self.headers, json=json_data) logger.info(f"请求函数:{func} 请求结果:{response.text}") return response.json()
def alter_bgcolor_byvalue(self,value,column,color_value,sheet_name): param = { 'value': value, 'column': column, 'color': color_value } return self.run_script('alter_bgcolor_byvalue',param,sheet_name)
def exist_byvalue(self,value,column,sheet_name): parma={ 'value': value, 'column': column } return self.run_script('exist_byvalue',parma,sheet_name)
def find_all_A_By_B(self,value,row,cell,column,sheet_name): param = { "value":value, "row": row, "cell": cell, "column": column } return self.run_script('find_all_A_By_B',param,sheet_name)['data']['result']
if __name__ == '__main__': api=KdocsApi('脚本令牌','webhook') api.alter_bgcolor_byvalue('ABCDEF','E:E',KColor.Pink,'Sheet1')
|