← 返回 Skills 市场
mousounikki

Jd Link Converter

作者 AlliWanttoDo · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ✓ 安全检测通过
41
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install jd-link-converter
功能描述
将京东移动端分享短链接(3.cn/u.jd.com)或移动端商品链接(item.m.jd.com)转换为PC端纯净商品链接(item.jd.com)。 当用户需要解析京东短链接、转换移动端链接为PC端链接、或批量处理京东商品链接时使用此技能。 触发场景包括用户粘贴京东分享链接、提到"京东链接转换"、"短链接转长链...
使用说明 (SKILL.md)

京东链接转换工具

我是京东链接转换工具,负责将移动端分享链接自动转换为PC端纯净商品链接。

触发条件

当用户消息中出现以下任一模式时触发本技能:

模式 示例
3.cn 短链接 https://3.cn/2RKwn3-g
u.jd.com 短链接 https://u.jd.com/abc123
移动端商品页 https://item.m.jd.com/product/100198170140.html
关键词触发 「京东链接转换」「短链接转长链接」「3.cn解析」「京东PC链接」

执行协议

Step 1: URL 分类与提取

从用户消息中提取所有匹配的 URL,按以下规则分类:

类型 识别规则 处理方式
3.cn 短链接 匹配 https?://3\.cn/ 需 HTTP 解析
u.jd.com 短链接 匹配 https?://u\.jd\.com/ 需 HTTP 解析
移动端商品页 匹配 item\.m\.jd\.com 直接提取 ID
PC端商品页(含参数) 匹配 item\.jd\.com/\d+ 去参数
纯商品 ID 6-12 位纯数字 直接拼接

Step 2: 链接解析

短链接(3.cn / u.jd.com):

执行脚本进行 HTTP 解析:

python3 {baseDir}/scripts/jd_link_converter.py "\x3Cshort_url>"

脚本会模拟京东 App User-Agent 跟踪 302 重定向,获取实际商品页面 URL。

重要: 3.cn 短链接必须使用 jdapp;iPhone;... 的 UA 才能正确跳转到商品页,普通浏览器 UA 会被重定向到京东首页。

也可使用 WebFetch 工具手动跟踪重定向,但需注意 UA 问题。

移动端 / PC端链接:

无需 HTTP 请求,直接用正则提取商品 ID。

Step 3: 生成 PC 端链接

从 URL 中提取 6-12 位数字商品 ID,拼接为:

https://item.jd.com/{id}.html

Step 4: 输出结果

对每个输入链接,输出结构化结果:

原始链接 类型 商品 ID PC 端链接
https://3.cn/2RKwn3-g 短链接 100198170140 https://item.jd.com/100198170140.html

批量转换时,以表格形式输出所有结果。

异常处理

异常场景 处理方式
短链接解析超时 提示用户提供移动端长链接或商品 ID
短链接已过期/失效 提示链接已失效,建议重新获取分享链接
非京东链接 跳过,不处理,提示用户确认链接是否正确
商品 ID 提取失败 提示 URL 格式异常,请检查链接完整性
网络不可用 使用内联正则从已知格式的 URL 中直接提取 ID(见下方内联方案)
3.cn 重定向到首页 提示可能 UA 被拦截,建议直接提供 item.m.jd.com 链接

内联转换方案(无需脚本,Agent 可直接执行)

当脚本不可用或网络受限时,Agent 可直接使用以下正则提取商品 ID:

import re

# 从各种京东 URL 格式中提取商品 ID
patterns = [
    r'item\.m\.jd\.com/product/(\d{6,12})\.html',
    r'item\.m\.jd\.com/(\d{6,12})\.html',
    r'item\.jd\.com/(\d{6,12})\.html',
    r'item\.jd\.com/(\d{6,12})',
]

def inline_extract(url: str) -> str | None:
    for pattern in patterns:
        match = re.search(pattern, url)
        if match:
            return match.group(1)
    return None

对于纯商品 ID(6-12 位数字),直接拼接:

pc_url = f"https://item.jd.com/{product_id}.html"

URL 格式速查

详细格式参考:{baseDir}/references/url_formats.md

快速参考

输入格式 转换结果
https://3.cn/xxx HTTP 解析 → 提取 ID → item.jd.com/{id}.html
https://u.jd.com/xxx HTTP 解析 → 提取 ID → item.jd.com/{id}.html
https://item.m.jd.com/product/{id}.html?utm_*=... 去参数 → item.jd.com/{id}.html
https://item.jd.com/{id}.html?cu=true 去参数 → item.jd.com/{id}.html
100198170140(纯 ID) 直接拼接 → item.jd.com/{id}.html
安全使用建议
Install if you want JD link cleanup and are comfortable with the skill contacting JD short-link hosts to resolve 3.cn or u.jd.com links. Avoid using it for sensitive/private links if outbound request metadata such as IP address, timing, and User-Agent matters in your environment.
能力评估
Purpose & Capability
The artifacts consistently describe JD link conversion, and the Python code implements URL classification, optional short-link resolution, product ID extraction, and clean item.jd.com output without unrelated capabilities.
Instruction Scope
The skill auto-triggers on JD links and related keywords; this is purpose-aligned, though broad keyword triggers could process incidental JD short links if an agent invokes it automatically.
Install Mechanism
Installation is a normal OpenClaw skill or Python package path using standard metadata and a console entry point; no hidden install hooks or third-party runtime dependencies are present.
Credentials
Short-link conversion performs outbound HTTP requests with a JD mobile User-Agent and follows redirects, which is proportionate to resolving JD short links but should be understood by privacy-sensitive users.
Persistence & Privilege
No persistence, background worker, credential access, local indexing, privilege escalation, file mutation, or destructive behavior was found.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install jd-link-converter
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /jd-link-converter 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
Added SKILL.md for OpenClaw/ClawHub compatibility, restructured directory (scripts/ + references/), dual-mode installation (clawhub + pip)
元数据
Slug jd-link-converter
版本 1.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Jd Link Converter 是什么?

将京东移动端分享短链接(3.cn/u.jd.com)或移动端商品链接(item.m.jd.com)转换为PC端纯净商品链接(item.jd.com)。 当用户需要解析京东短链接、转换移动端链接为PC端链接、或批量处理京东商品链接时使用此技能。 触发场景包括用户粘贴京东分享链接、提到"京东链接转换"、"短链接转长链... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 41 次。

如何安装 Jd Link Converter?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install jd-link-converter」即可一键安装,无需额外配置。

Jd Link Converter 是免费的吗?

是的,Jd Link Converter 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Jd Link Converter 支持哪些平台?

Jd Link Converter 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Jd Link Converter?

由 AlliWanttoDo(@mousounikki)开发并维护,当前版本 v1.1.0。

💬 留言讨论