使用bat从{"media_type":2,"has_dash_audio":true,"is_completed":true,"total_bytes":54528541,"downloaded_bytes":54528541,"title":"【稚雨】宇宙 ૮ ´͈ ᗜ `͈ ა♡|ユニバース","type_tag":"112","cover":"http:\/\/i0.hdslb.com\/bfs\/archive\/aacd3a3a3397a4ca7426ff9ac237d57bd5ea5b6d.jpg","video_quality":112,"prefered_video_quality":112,"guessed_total_bytes":0,"total_time_milli":252543,"danmaku_count":33,"time_update_stamp":1689402493484,"time_create_stamp":1689402474935,"can_play_in_advance":true,"interrupt_transform_temp_file":false,"quality_pithy_description":"1080P","quality_superscript":"高码率","cache_version_code":7370300,"preferred_audio_quality":0,"audio_quality":0,"avid":870875619,"spid":0,"seasion_id":0,"bvid":"BV15V4y1b7Xv","owner_id":344270893,"owner_name":"稚雨才不是至于","owner_avatar":"https:\/\/i1.hdslb.com\/bfs\/face\/a3175ec8b252285ff802beedd8fe099016b90ea5.jpg","page_data":{"cid":1196836330,"page":1,"from":"vupload","part":"宇宙","link":"","vid":"","has_alias":false,"tid":20,"width":1920,"height":1080,"rotate":0,"download_title":"视频已缓存完成","download_subtitle":"【稚雨】宇宙 ૮ ´͈ ᗜ `͈ ა♡|ユニバース 宇宙"}}之中提取题目
时间: 2023-07-24 14:14:35 浏览: 294
dash_template_dashboard:破折号应用程序的模板
你可以使用 Batch 脚本中的字符串操作来提取 JSON 数据中的 `title` 字段。下面是一个示例脚本:
```batch
@echo off
setlocal enabledelayedexpansion
set "json={"media_type":2,"has_dash_audio":true,"is_completed":true,"total_bytes":54528541,"downloaded_bytes":54528541,"title":"【稚雨】宇宙 ૮ ´͈ ᗜ `͈ ა♡|ユニバース","type_tag":"112","cover":"http:\/\/i0.hdslb.com\/bfs\/archive\/aacd3a3a3397a4ca7426ff9ac237d57bd5ea5b6d.jpg","video_quality":112,"preferred_video_quality":112,"guessed_total_bytes":0,"total_time_milli":252543,"danmaku_count":33,"time_update_stamp":1689402493484,"time_create_stamp":1689402474935,"can_play_in_advance":true,"interrupt_transform_temp_file":false,"quality_pithy_description":"1080P","quality_superscript":"高码率","cache_version_code":7370300,"preferred_audio_quality":0,"audio_quality":0,"avid":870875619,"spid":0,"seasion_id":0,"bvid":"BV15V4y1b7Xv","owner_id":344270893,"owner_name":"稚雨才不是至于","owner_avatar":"https:\/\/i1.hdslb.com\/bfs\/face\/a3175ec8b252285ff802beedd8fe099016b90ea5.jpg","page_data":{"cid":1196836330,"page":1,"from":"vupload","part":"宇宙","link":"","vid":"","has_alias":false,"tid":20,"width":1920,"height":1080,"rotate":0,"download_title":"视频已缓存完成","download_subtitle":"【稚雨】宇宙 ૮ ´͈ ᗜ `͈ ა♡|ユニバース 宇宙"}}"
set "title=!json:*\"title\":\"=!"
set "title=!title:~0,-1!"
echo %title%
```
在上述脚本中,我将 JSON 数据存储在 `json` 变量中。然后使用字符串操作来提取 `title` 字段。
首先,使用 `set "title=!json:*\"title\":\"=!"` 将 `title` 变量设置为从 JSON 数据中删除 `title":"` 后的内容。
然后,使用 `set "title=!title:~0,-1!"` 去除最后一个字符(JSON 数据中的双引号),得到最终的题目内容。
请注意,脚本中的字符串操作可能需要根据你的实际情况进行修改。
阅读全文