python 连接 nacos
import nacos SERVER_ADDRESSES = "10.2.2.10:8848" NAMESPACE = "8f69a418-3d32-4c55-99c6-beb88a56c380" # auth mode client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE,username="lifuqaing",password="123456") # # get config group = "DEFAULT_GROUP" # # 返回是字符串 print(client.get_config(data_id, group))
使用curl请求nacos
# curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=hahaha&group=hehehe&tenant=a4dbd1b3-5b25-4e68-9c13-c1bc7a082013"
使用requests模块
import requests import yaml url = "http://192.168.9.35:8848/nacos/v1/cs/configs?dataId=client.yaml&group=DEFAULT_GROUP&tenant=ffb5b4c2-91d8-4c78-81f8-415992a82491" res = requests.get(url=url) data = yaml.load(res.text,Loader=yaml.FullLoader) print(data)