Flutter URL处理或命令执行插件oghref_cmd的使用方法详解
Flutter URL处理或命令执行插件oghref_cmd的使用方法详解
命令行工具用于查看解析后的丰富信息链接元数据和数据交换
本包仅作为可执行文件提供,既作为pub包又作为单独编译的可执行文件。
插件oghref_cmd的安装
下载可执行文件
警告
该软件包仅支持AMD64 CPU架构和Apple Silicon(自0.1.1
版本起)。对于其他受Dart支持的CPU架构,请考虑自行编译。
注意
在ARM64(Apple silicon)版本的macOS上,通过Codemagic编译。
请从这里下载最新版本。
使用 dart pub
命令
如果已经安装了Dart,则可以通过运行以下命令来部署:
dart pub global activate oghref_cmd
编辑 pubspec.yaml
请将 oghref_cmd
添加到 dev_dependencies
中,而不是 dependencies
:
dev_dependencies:
oghref_cmd: # 复制版本约束来自pub.dev
编译
首先获取Dart SDK并执行以下命令:
# 假设Dart二进制文件已定义到PATH中
git clone --depth 1 --branch release https://github.com/rk0cc/oghref_cmd.git
mkdir dist
dart pub get
dart compile exe bin/oghref_cmd.dart -o dist/oghref_cmd
插件oghref_cmd的使用方法
Usage: oghref_cmd <command> [arguments]
全局选项:
-h, --help 打印此使用信息。
可用命令:
info 获取给定URL中的元数据信息
json 以JSON格式导出抓取的内容
media 打印给定URL中的媒体信息
version 获取oghref_cmd的版本。
对于每个命令的用法,请输入:
oghref_cmd <命令名> -h
或者访问此处。
许可证
AGPL v3
示例
这些示例将列出三个功能子命令 info
、media
和 json
,并附有执行结果和输出文档(仅限 json
子命令)。
在此示例中,我们将引用位于 官方Flutter网站 的元数据。
获取元数据信息
oghref_cmd info https://flutter.dev
Data found using og:
┌──────────┐
│og context│
└────┬─────┘
├── title: Flutter - Build apps for any screen
├── description: Flutter transforms the entire app development process. Build, test, and deploy beautiful mobile, web
│ , desktop, and embedded apps from a single codebase.
└── url: //flutter.dev/
Media summary:
Category Counts
Images: 1
获取元数据中的媒体信息
oghref_cmd media https://flutter.dev
Media found in og:
┌──────┐
│Images│
└──┬───┘
└── 0
└── url: https://storage.googleapis.com/cms-storage-bucket/70760bf1e88b184bb1bc.png
将元数据导出为带缩进的JSON格式
oghref_cmd json --indent=4 https://flutter.dev
{
"og": {
"site_name": null,
"title": "Flutter - Build apps for any screen",
"description": "Flutter transforms the entire app development process. Build, test, and deploy beautiful mobile, web, desktop, and embedded apps from a single codebase.",
"url": "//flutter.dev/",
"images": [
{
"url": "https://storage.googleapis.com/cms-storage-bucket/70760bf1e88b184bb1bc.png",
"secure_url": null,
"type": null,
"width": null,
"height": null,
"alt": null
}
],
"videos": [],
"audios": []
}
}
更多关于Flutter URL处理或命令执行插件oghref_cmd的使用方法详解的实战教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复