home / skills / openclaw / skills / travel-cn

This skill helps you compare flight, hotel, and train options across travel platforms and plan trips efficiently.

npx playbooks add skill openclaw/skills --skill travel-cn

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
2.0 KB
---
name: travel-cn
description: 旅行信息查询 - 去哪儿/携程/飞猪数据查询(Expedia 中国版)
metadata:
  openclaw:
    emoji: "✈️"
    category: "travel"
    tags: ["travel", "qunar", "ctrip", "fliggy", "china", "booking"]
---

# 旅行信息查询

去哪儿/携程/飞猪数据查询。

## 功能

- ✈️ 机票查询
- 🏨 酒店预订
- 🚄 火车票
- 🎫 景点门票
- 📅 行程规划

## 平台对比

| 平台 | 机票 | 酒店 | 火车 | 特点 |
|------|-----|------|------|------|
| **携程** | ✅ | ✅ | ✅ | 全能 |
| **去哪儿** | ✅ | ✅ | ✅ | 比价 |
| **飞猪** | ✅ | ✅ | ❌ | 阿里系 |
| 12306 | ❌ | ❌ | ✅ | 官方 |

## 机票查询

### 携程 API

```bash
# 需要合作伙伴资质
curl "https://api.ctrip.com/flight/search?from=SHA&to=PEK&date=2026-02-20"
```

### 爬虫方案

```python
# 使用 selenium
pip install selenium

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://flight.qunar.com/")
```

## 酒店查询

### 携程 API

```bash
curl "https://api.ctrip.com/hotel/search?city=上海&checkin=2026-02-20"
```

## 火车票查询

### 12306(官方)

```bash
# 使用 12306 API 封装
pip install py12306

from py12306 import Py12306
client = Py12306()
trains = client.query("上海", "北京", "2026-02-20")
```

## 使用场景

### 1. 商务出行

- 机票/酒店比价
- 行程优化
- 费用控制

### 2. 旅行规划

- 景点推荐
- 路线规划
- 预算管理

### 3. 价格监控

- 降价提醒
- 价格趋势
- 最佳购买时机

## 快速脚本

```bash
# 查询机票
./scripts/flight-search.sh --from 上海 --to 北京 --date 2026-02-20

# 查询酒店
./scripts/hotel-search.sh --city 上海 --checkin 2026-02-20

# 查询火车票
./scripts/train-search.sh --from 上海 --to 北京 --date 2026-02-20
```

## 注意事项

1. **API 限制**: 需要合作伙伴资质
2. **爬虫风险**: 可能被封 IP
3. **价格变化**: 实时波动

---

*版本: 1.0.0*

Overview

This skill provides consolidated travel information queries across major Chinese travel platforms, offering flight, hotel, train, and attraction data. It aggregates available APIs and recommended scraping approaches for cases where official APIs require partnership credentials. The skill focuses on practical scripts and integration points for price comparison, itinerary planning, and monitoring.

How this skill works

The skill outlines how to query flight and hotel APIs (when partner access is available) and presents lightweight scraping patterns for public web pages using browser automation. It includes references to an official train API wrapper for 12306 and simple shell scripts to run common searches. Guidance covers data sources, basic request examples, and caveats like rate limits and blocking risks.

When to use it

  • When you need cross-platform price comparison for flights and hotels
  • When partner API credentials are unavailable but timely data is required
  • For automating routine queries: fare tracking, availability checks, itinerary building
  • When integrating train schedule queries using 12306 official wrappers
  • For prototyping travel search features before formal API partnerships

Best practices

  • Prefer official APIs when you have partner credentials to avoid scraping risks
  • Implement rate limiting, retries, and rotating IPs if using browser automation
  • Cache results and store timestamps to handle price volatility and reduce query load
  • Respect terms of service and local regulations; log errors and monitor blocking
  • Use small, focused scripts for repeatable queries and centralize credential storage

Example use cases

  • Automated fare comparison across Ctrip, Qunar, and Alitrip-like sources for corporate travel teams
  • Nightly price-monitoring job that alerts when fares or hotel rates drop
  • Integrating train availability checks into a trip planner using the 12306 wrapper
  • On-demand itinerary builder that combines flights, trains, hotels, and attractions into a single plan
  • Rapid prototype of a travel search frontend backed by shell scripts and simple Python scrapers

FAQ

Are unofficial scrapers legal and safe to use?

Scraping public pages may violate terms of service and can trigger IP blocks; prefer official APIs and obtain permissions when possible.

Do I need partner credentials to get full data?

Yes—many platforms restrict full API access to certified partners; scraping is a fallback but has limits and risks.