A Ctrip-based flight price monitor. You only need to fill routes in config.json with departure city, arrival city, and departure date. The program will resolve supported Ctrip cities, build the page URL internally, fetch prices, and send notifications when prices meet your threshold.
- Config-only workflow; define routes only in
config.json - Supports exported cookie.json login cookies for full itinerary crawling; if cookies are missing or expired, the program falls back automatically
- Auto-resolves Ctrip domestic city code and city ID from the live site
- Builds the Ctrip one-way list URL from
departure_city,arrival_city, anddeparture_date - Uses itinerary API data first, falls back to DOM parsing, and finally falls back to Ctrip lowest-price APIs (12808/lowestPrice and calendar pricing) when only route/date pricing is available
- Keeps price history and shows recent price movement
- Supports PushPlus HTML notifications
- Supports Resend email notifications
- Supports one-shot CLI mode and scheduled service mode
- Supports Docker and Docker Compose deployment
- Install dependencies
pip install -r requirements.txt- Prepare a browser
Install Chromium or Chrome locally. If auto-detection fails, set config.json -> browser.executable_path.
- Copy the template
cp config.example.json config.json- Edit
config.json
If you export your logged-in Ctrip cookies to cookie.json in the project root, the crawler will load them automatically before opening the flight page. This is recommended because the logged-in itinerary API returns full flight details more reliably.
Important fields:
pushplus.tokenemail.api_keyemail.fromemail.toservice.schedule_timesservice.capture_lead_minutesroutes
Each item in routes should contain:
departure_cityarrival_citydeparture_dateexpected_priceenabled
Example:
The program builds a Ctrip page URL like this internally:
https://flights.ctrip.com/online/list/oneway-bjs-sha?depdate=2026-04-15&cabin=y_s_c_f&adult=1&child=0&infant=0
Run once and send notifications:
python flight_monitor.pyDry run and print JSON only:
python flight_monitor.py --dry-run --dump-jsonRun as a scheduled service:
python flight_monitor.py --servicedocker build -t ctrip-flight-alter .
docker run --rm --user root -v $(pwd):/app ctrip-flight-alterghcr.io/youyi0218/ctrip-flight-alter:latest
docker compose up -dflight_monitor.pyrequirements.txtconfig.example.jsondocker-compose.ymlDockerfile.gitignore.dockerignoredocker-entrypoint.shLICENSE
docker login ghcr.io -u youyi0218
docker compose pull
docker compose up -dIf you only changed local config:
docker compose restartCheck logs:
docker compose logs -fStop service:
docker compose downRecommended first check:
python flight_monitor.py --dry-run --dump-json
{ "departure_city": "YOUR_DEPARTURE_CITY", "arrival_city": "YOUR_ARRIVAL_CITY", "departure_date": "2026-12-31", "expected_price": 500, "enabled": true }