[Eagle API]使用python打印eagle指定文件夹下的所有子文件名

api:https://www.yuque.com/augus-gsjgn/eagle-api/pq0y2y

//官方api源码
var requestOptions = {
  method: 'GET',
  redirect: 'follow'
};

fetch("http://localhost:41595/api/folder/list?token=YOUR_API_TOKEN", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

输出结果

[Eagle API]使用python打印eagle指定文件夹下的所有子文件名_第1张图片

python代码

import requests

url = "http://localhost:41595/api/folder/list?token=YOUR_API_TOKEN"

response = requests.get(url)
data = response.json()

if response.status_code == 200 and data["status"] == "success":
    folder = data["data"][5]  # 获取我的第六个文件夹
    children = folder["children"]
    children_names = [child["name"] for child in children]
    
    print("Children:")
    for name in children_names:
        print(name)
else:
    print("Error occurred:", data)

你可能感兴趣的:(python,开发语言,eagle)