https://media.rightmove.co.uk/ps/pdf/guides/adf/Rightmove_Real_Time_Datafeed_Specification.pdf
因此,我查看了 RightMove API 的文档,它在第 5 页上说,它们根据开发环境为您提供了所有三个文件。
因此,为此我们将使用该.pem
文件。
const https = require('https')
const fs = require('fs')
const axios = require('axios')
const key = fs.readFileSync('./key.pem')
const ca = fs.readFileSync('./ca.crt')
const url = 'https://adfapi.rightmove.co.uk/'
const httpsAgent = new https.Agent({
rejectUnauthorized: true, // Set to false if you dont have the CA
key,
ca,
passphrase: 'YYY', // Would recommend storing as secret
keepAlive: false,
})
const axiosInstance = axios.create({ headers: { 'User-Agent': 'rightmove-datafeed/1.0' }, httpsAgent })
axiosInstance.get(url, { httpsAgent })
我注意到文档说某些与 RightMove 一起使用的 API,您需要设置自定义User-Agent
. 文档提到他们有 JSON 或 XML 模式可供下载这里。您还可以查看示例响应。
因为您很可能会进行多次调用,所以我创建了一个 axios 实例,这意味着您只需为所有请求设置一次这些选项。