crawlbase文档
登录

API 用法

Crawling API 请求中添加 &scraper=booking-serp。在 url 参数中对目标 URL 进行 URL 编码。

curl 'https://api.crawlbase.com/?token=YOUR_TOKEN' \
  --data-urlencode 'url=https://www.booking.com/searchresults.html?ss=Amsterdam' \
  --data-urlencode 'scraper=booking-serp' -G
from crawlbase import CrawlingAPI

api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
    'https://www.booking.com/searchresults.html?ss=Amsterdam',
    {'scraper': 'booking-serp'}
)

import json
data = json.loads(res['body'])
const { CrawlingAPI } = require('crawlbase');
const api = new CrawlingAPI({ token: 'YOUR_TOKEN' });

const res = await api.get(
  'https://www.booking.com/searchresults.html?ss=Amsterdam',
  { scraper: 'booking-serp' }
);
const data = JSON.parse(res.body);
require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')

res = api.get('https://www.booking.com/searchresults.html?ss=Amsterdam', scraper: 'booking-serp')
data = JSON.parse(res.body)

示例输入 URL

传入 url 参数的 URL(为便于阅读已 URL 解码):

https://www.booking.com/searchresults.html?ss=Amsterdam

响应结构

JSON 响应体。当源页面省略对应值时,字段类型可能为 null

searchUrl
string
规范的搜索结果 URL。
destination
string
执行搜索所针对的目的地。
propertyCount
integer
properties 中返回的房源数量。
properties
array
与搜索匹配的房源,按 Booking.com 返回的顺序排列。
properties[].name
string
房源名称。
properties[].url
string
房源的规范 Booking.com URL。
properties[].address
string
房源地址。
properties[].distance
string | null
距目的地中心的距离(如存在)。
properties[].price
string
列表中显示的已格式化价格文本。
properties[].priceAmount
number | null
数值型价格,若无法解析则为 null。
properties[].currency
string | null
价格的货币代码(如存在)。
properties[].reviewScore
number | null
平均评论分数,若无评论则为 null。
properties[].reviewCount
integer | null
评论数量,若无评论则为 null。
properties[].rating
integer | null
房源的星级评定,若未评定则为 null。
properties[].image
string | null
缩略图图片 URL(如存在)。

示例响应

{
  "searchUrl": "https://www.booking.com/searchresults.html?ss=Amsterdam",
  "destination": "Amsterdam",
  "propertyCount": 2,
  "properties": [
    {
      "name": "Canal House Amsterdam",
      "url": "https://www.booking.com/hotel/nl/canal-house-amsterdam.html",
      "address": "Keizersgracht 148, Amsterdam City Center, 1015 CX Amsterdam",
      "distance": "0.8 km from centre",
      "price": "€ 245",
      "priceAmount": 245,
      "currency": "EUR",
      "reviewScore": 9.1,
      "reviewCount": 1284,
      "rating": 4,
      "image": "https://cf.bstatic.com/xdata/images/hotel/canal-house.jpg"
    },
    {
      "name": "Jordaan Boutique Stay",
      "url": "https://www.booking.com/hotel/nl/jordaan-boutique-stay.html",
      "address": "Prinsengracht 302, Jordaan, 1016 HX Amsterdam",
      "distance": "1.2 km from centre",
      "price": "€ 189",
      "priceAmount": 189,
      "currency": "EUR",
      "reviewScore": 8.7,
      "reviewCount": 642,
      "rating": 3,
      "image": null
    }
  ]
}