← 返回 Skills 市场
andrew-707

ctrip-flight

作者 Andrew-707 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
122
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install ctrip-flight-sunrise
功能描述
Search and compare flight tickets on Ctrip by departure, arrival, date, and cabin class, returning structured flight and price information in JSON format.
使用说明 (SKILL.md)

携程机票查询 Skill

概述

用于从携程网站搜索机票信息,获取地点、时间、价格、航班等结构化数据,支持比价分析、直飞/中转识别等功能。

技术实现

  • 数据来源: https://flights.ctrip.com
  • 认证方式: Cookie (FVP cookie from flights.ctrip.com)
  • 数据提取: 解析页面 JavaScript 中的 JSON 数据
  • 支持功能: 单程搜索、多日期比价

核心能力

  1. 机票搜索 - 根据出发地、目的地、日期搜索航班
  2. 数据提取 - 解析航班信息(航空公司、时刻、价格、机型等)
  3. 结构化存储 - 输出 JSON 格式的航班数据
  4. 比价分析 - 多日期、多航班价格对比
  5. 低价监控 - 监控特定航线价格变化

搜索脚本使用

# 基本搜索
python3 scripts/ctrip_flight.py -d 北京 -a 上海 -t 2026-04-01

# 输出JSON文件
python3 scripts/ctrip_flight.py -d 北京 -a 上海 -t 2026-04-01 -o result.json

# 多日期比价
python3 scripts/ctrip_flight.py -d 北京 -a 上海 -t 2026-04-01 --compare 2026-04-01,2026-04-02,2026-04-03

搜索参数

参数 说明 示例
-d, --departure 出发城市 北京
-a, --arrival 到达城市 上海
-t, --date 出发日期 (YYYY-MM-DD) 2026-04-01
-c, --cabin 舱位类型 (y/c/f) y (经济舱)
-o, --output 输出JSON文件路径 result.json
--compare 多日期对比,逗号分隔 2026-04-01,2026-04-02

输出格式

{
  "searchParams": {
    "departure": "BJS",
    "departureName": "北京",
    "arrival": "SHA",
    "arrivalName": "上海",
    "date": "2026-04-01",
    "cabin": "y"
  },
  "flights": [
    {
      "flightNo": "HO1254",
      "airline": "吉祥航空",
      "airlineCode": "HO",
      "depTime": "2026-04-01 21:25:00",
      "arrTime": "2026-04-01 23:35:00",
      "duration": 130,
      "depAirport": "大兴",
      "depAirportCode": "PKX",
      "arrAirport": "浦东",
      "arrAirportCode": "PVG",
      "planeType": "空客320",
      "stops": 0,
      "isDirect": true,
      "price": 450
    }
  ],
  "statistics": {
    "totalFlights": 11,
    "directFlights": 11,
    "transitFlights": 0,
    "lowestPrice": 450,
    "highestPrice": 550,
    "avgPrice": 516
  },
  "searchTime": "2026-03-27T18:07:42"
}

Cookie 配置

当前使用预设的 FVP cookie。如需更新:

  1. 在 Chrome 中登录携程 flights.ctrip.com
  2. 打开开发者工具 (F12) -> Application -> Cookies
  3. 复制 FVP cookie 的值
  4. 更新脚本中的 self.cookie 变量

已知限制

  • Cookie 有时效性,可能需要定期更新
  • 部分特殊航班数据可能不完整
  • 经停航班的价格数据可能比直飞航班少

城市代码支持

支持中国主要城市: 北京(BJS), 上海(SHA), 广州(CAN), 深圳(SZX), 成都(CTU), 杭州(HGH), 南京(NKG), 武汉(WUH), 西安(XIY), 重庆(CKG), 厦门(XMN), 长沙(CSX), 昆明(KMG), 大连(DLC), 青岛(TAO), 天津(TSN), 郑州(CGO), 福州(FOC), 沈阳(SHE), 哈尔滨(HRB) 等

文件结构

skills/ctrip-flight/
├── skill.md           # 本文档
├── README.md          # 使用说明
└── scripts/
    ├── ctrip_flight.py    # 主搜索脚本
    └── ctrip_search.py    # 备用搜索脚本
安全使用建议
This skill appears to do what it claims (scraping flights.ctrip.com and returning JSON). Before installing: (1) be aware it scrapes Ctrip and performs network requests to flights.ctrip.com/m.ctrip.com; (2) it uses an FVP session cookie — do not paste sensitive or shared cookies into files you will share; prefer placing your cookie in a local environment variable or config file instead of editing source code; (3) the repository includes a hardcoded cookie default — replace or remove it to avoid acting as another user's session; (4) scraping a website can violate terms of service and may break if Ctrip changes page structure, so test on non-production data and monitor for failures; (5) review the full scripts locally to ensure no unexpected outgoing endpoints or telemetry are added before use.
能力评估
Purpose & Capability
Name/description match the included scripts: the code and data focus on locating airports, parsing Ctrip flight pages, aggregating and outputting JSON. Required capabilities (HTTP requests, parsing) are proportional to the stated goal.
Instruction Scope
SKILL.md explicitly tells the user to obtain an FVP cookie from flights.ctrip.com and paste it into the script's self.cookie variable. That is consistent with the scraping approach but requires editing code and exposing a session cookie in local files; the instructions do not ask the agent to read unrelated system files or other credentials.
Install Mechanism
No install spec; skill is instruction + local scripts only. No external downloads or installers are used, lowering installation risk.
Credentials
The skill needs a Ctrip session cookie to access data; SKILL.md documents this, but the project also ships with a hardcoded FVP cookie default in ctrip_flight.py. Using or embedding session cookies in code is a privacy/operational concern — it would be more appropriate to accept the cookie via a secure environment variable or config file.
Persistence & Privilege
No special persistence or always-enabled flag. The skill runs when invoked and does not request system-level privileges or modify other skills.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install ctrip-flight-sunrise
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /ctrip-flight-sunrise 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- 全新实现,Skill 完全由“AI机票助手”更换为“携程航班爬虫”方案 - 精简功能,仅保留机票搜索、航班信息提取与比价分析,移除鉴权、下单、退改签、订单等功能 - 采用携程前端 Cookie 认证,调用脚本直接解析网页 JSON 数据获取结构化航班信息 - 新增多日期比价、直飞/中转识别、价格监控等能力,支持命令行参数灵活搜索 - 输出结果仅为结构化 JSON 数据,便于后续处理或展示
元数据
Slug ctrip-flight-sunrise
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

ctrip-flight 是什么?

Search and compare flight tickets on Ctrip by departure, arrival, date, and cabin class, returning structured flight and price information in JSON format. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 122 次。

如何安装 ctrip-flight?

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

ctrip-flight 是免费的吗?

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

ctrip-flight 支持哪些平台?

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

谁开发了 ctrip-flight?

由 Andrew-707(@andrew-707)开发并维护,当前版本 v1.0.0。

💬 留言讨论