Booking.com Extranet Manager
Automate Booking.com property management through a Python CLI tool. Uses your locally installed Google Chrome (not a headless browser) to interact with the Booking.com partner extranet, avoiding bot detection.
Security Notes
- - Credentials are stored locally in a
.env file in the bot directory — never transmitted elsewhere. - Browser session is persisted in
.chrome-data/ so login + SMS 2FA only happens once. Delete this directory to clear the session. - Chrome remote debugging runs on
localhost:9222 only — not exposed to the network. - The bot connects exclusively to
admin.booking.com and account.booking.com.
Prerequisites
The CLI tool must be installed and configured on the host machine:
CODEBLOCK0
Then create a .env file with your credentials:
CODEBLOCK1
Google Chrome must be installed on the host machine.
Environment
- -
BOT_DIR: Absolute path to the booking-extranet-bot directory - Python venv at INLINECODE7
- CLI entry point: INLINECODE8
All commands output JSON to stdout. Logs go to stderr.
Available Commands
List Properties
Get all properties with hotel IDs and unread message counts.
CODEBLOCK2
Returns:
CODEBLOCK3
Download Reservations
Download reservations for a date range. Use --json to get data directly, or omit it to save an Excel file.
CODEBLOCK4
Options:
- -
--start YYYY-MM-DD (required): Start date - INLINECODE11 (required): End date
- INLINECODE12 :
arrival (default), departure, or INLINECODE15 - INLINECODE16 : Return data as JSON instead of Excel
- INLINECODE17 : Directory for Excel file (default:
./downloads)
List Messages
List guest messages for a property. Defaults to unanswered.
CODEBLOCK5
Options:
- -
--hotel-id (required): Property hotel ID from list-properties - INLINECODE20 :
unanswered (default), sent, or INLINECODE23
Read Message
Open and read a specific conversation with reservation details.
CODEBLOCK6
Options:
- -
--hotel-id (required): Property hotel ID - INLINECODE25 (required): Message index from list-messages (0-based)
Send Message
Reply to a guest conversation. Always use list-messages first to get the correct index.
CODEBLOCK7
Options:
- -
--hotel-id (required): Property hotel ID - INLINECODE27 (required): Message index from list-messages (0-based)
- INLINECODE28 (required): Reply text
Update Rates
Update room rates from the CSV pricing file.
CODEBLOCK8
Typical Workflow
- 1. List properties to get hotel IDs and see which have unread messages
- List messages for properties with unread messages
- Read each conversation to understand the guest's request
- Send replies as appropriate
- Download reservations periodically to track bookings
First Run
On first run, Chrome opens and you must complete the login (including SMS 2FA). Subsequent runs reuse the session — no login needed until the session expires.
Booking.com Extranet Manager
通过Python CLI工具自动化管理Booking.com房源。使用本地安装的Google Chrome(非无头浏览器)与Booking.com合作伙伴外网交互,避免机器人检测。
安全说明
- - 凭证 存储在机器人目录下的.env文件中,绝不传输至其他位置。
- 浏览器会话 持久化保存在.chrome-data/目录中,因此登录和短信双重验证仅需一次。删除此目录即可清除会话。
- Chrome远程调试 仅在localhost:9222上运行,不暴露于网络。
- 机器人仅连接至admin.booking.com和account.booking.com。
前提条件
CLI工具必须在主机上安装并配置:
bash
git clone https://github.com/matsei-ruka/booking-extranet-bot.git
cd booking-extranet-bot
python3 -m venv venv
source venv/bin/activate # Linux/macOS
pip install -r requirements.txt
然后创建包含凭证的.env文件:
BOOKINGUSERNAME=yourlogin_name
BOOKINGPASSWORD=yourpassword
BOOKINGHOTELID=yourdefaulthotel_id # 可选
主机上必须安装Google Chrome。
环境
- - BOTDIR:booking-extranet-bot目录的绝对路径
- Python虚拟环境位于$BOTDIR/venv/bin/python3
- CLI入口点:$BOT_DIR/cli.py
所有命令输出JSON到标准输出。日志输出到标准错误。
可用命令
列出房源
获取所有房源及其酒店ID和未读消息数量。
bash
cd $BOT_DIR && source venv/bin/activate && python3 cli.py list-properties
返回:
json
{
status: success,
action: list-properties,
count: 3,
properties: [
{hotelid: 10353912, name: Property Name, unreadmessages: 4}
]
}
下载预订
下载指定日期范围内的预订。使用--json直接获取数据,省略此参数则保存为Excel文件。
bash
以JSON格式(用于处理)
cd $BOT_DIR && source venv/bin/activate && python3 cli.py download-reservations --start 2026-03-01 --end 2026-09-30 --json
以Excel文件格式
cd $BOT_DIR && source venv/bin/activate && python3 cli.py download-reservations --start 2026-03-01 --end 2026-09-30
选项:
- - --start YYYY-MM-DD(必填):开始日期
- --end YYYY-MM-DD(必填):结束日期
- --date-type:arrival(默认)、departure或booking
- --json:以JSON格式返回数据而非Excel
- --output-dir:Excel文件的保存目录(默认:./downloads)
列出消息
列出房源的客人消息。默认显示未回复消息。
bash
cd $BOT_DIR && source venv/bin/activate && python3 cli.py list-messages --hotel-id 10353912
选项:
- - --hotel-id(必填):来自list-properties的房源酒店ID
- --filter:unanswered(默认)、sent或all
阅读消息
打开并阅读特定对话及其预订详情。
bash
cd $BOT_DIR && source venv/bin/activate && python3 cli.py read-message --hotel-id 10353912 --index 0
选项:
- - --hotel-id(必填):房源酒店ID
- --index(必填):来自list-messages的消息索引(从0开始)
发送消息
回复客人对话。始终先使用list-messages获取正确的索引。
bash
cd $BOT_DIR && source venv/bin/activate && python3 cli.py send-message --hotel-id 10353912 --index 0 --message 感谢您的留言
选项:
- - --hotel-id(必填):房源酒店ID
- --index(必填):来自list-messages的消息索引(从0开始)
- --message(必填):回复文本
更新房价
从CSV定价文件更新房价。
bash
cd $BOT_DIR && source venv/bin/activate && python3 cli.py update-rates
cd $BOT_DIR && source venv/bin/activate && python3 cli.py update-rates --hotel-id 13616005
典型工作流程
- 1. 列出房源以获取酒店ID并查看哪些有未读消息
- 列出消息针对有未读消息的房源
- 阅读每个对话以了解客人的请求
- 发送回复根据情况回复
- 下载预订定期下载以跟踪预订情况
首次运行
首次运行时,Chrome会打开,您需要完成登录(包括短信双重验证)。后续运行会重用会话,无需再次登录,直到会话过期。