网页抓取时如何从脚本中获取信息?

时间:2020-08-27 12:26:25

标签: javascript node.js axios cheerio roblox

我正在从网页上抓取信息,除此以外,我已经能够获取所有信息:一个带有令牌的脚本。目前,我已经向网页提出了获取请求,并且看到了它返回脚本的位置。我的代码是:

const axios = require('axios');
const cheerio = require('cheerio');

const buyItem = async (cookie, assetId) => {
    // Get x-csrf-token, product id, and price
    await axios.default.request({
        url: `https://www.roblox.com/catalog/${assetId}`,
        method: "GET",
        headers: {Cookie: `.ROBLOSECURITY=${cookie};`}
    }).then(response => {
        const $ = cheerio.load(response.data);
        console.log(response)
    })
};

0 个答案:

没有答案