希望有人能帮我。我在试着理解qBittorrent网络API。目前,我正在列出所有暂停的洪流:
curl -i http://localhost:8080/api/v2/torrents/info?category=test问题是,列出了整个JSON数组--我的问题是,我能否只显示"name“或”散列“字段?这都是通过cmd使用curl的,但是我已经在Git Bash &Powershell中尝试过这样的方法:
[{"eta":8640000,"f_l_piece_prio":false,"force_start":false,"hash":"8419d48d86a14335c83fdf4930843438a2f75a6b","last_activity":1664863523,"magnet_uri":"","max_seeding_time":0,"**name**":"TestTorrentName","num_complete":12,"num_incomplete":1,"num_leechs":0,"num_seeds":0,"priority":0,"progress":1,"ratio":0,"ratio_limit":-2,"save_path":"F:\\Completed\\test\\","seeding_time":0,"seeding_time_limit":-2,"seen_complete":1664863523,"seq_dl":false,"size":217388295,"state":"pausedUP","super_seeding":false,"tags":"","time_active":569,"total_size":217388295,"tracker":"udp://open.stealth.si:80/announce","trackers_count":10,"up_limit":-1,"uploaded":0,"uploaded_session":0,"upspeed":0}]根据https://jqplay.org/,我已经尝试了以下几种应该有效的方法--参见屏幕截图
curl -i http://localhost:8080/api/v2/torrents/info?category=test | jq --raw-output '.[] | .name'但不幸的是,我得到了以下错误:
curl -i http://localhost:8080/api/v2/torrents/info?category=test | jq --raw-output '.[] | .name'
% Total % Received % Xferd Average Speed Time '.name'' is not recognized as an internal or external command,
operable program or batch file.
Ti发布于 2022-10-04 11:32:55
curl -i http://localhost:8080/api/v2/torrents/info?category=test | jq --raw-output '.[] | .name'-i让curl提供一些头部信息,这些信息被解析为jq,但是jq只能解析JSON,因此失败。
删除-i,并将其替换为-s以删除统计数据:
curl -s http://localhost:8080/api/v2/torrents/info?category=test | jq --raw-output '.[] | .name'https://stackoverflow.com/questions/73946917
复制相似问题