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

文章展示了如何使用JavaScript的fetchAPI和Python的requests库来发送GET请求到指定URL获取数据。在JavaScript示例中,数据被转换为JSON并打印。Python部分演示了如何处理响应,获取第六个文件夹的信息,并列出其子文件夹的名称。当HTTP状态码为200且响应数据状态为success时,程序才执行数据提取。
摘要由CSDN通过智能技术生成

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));

输出结果

在这里插入图片描述

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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值