邮递员拦截器请求永远运行

时间:2021-04-08 10:24:48

标签: google-chrome web-scraping get postman google-chrome-devtools

我试图拦截一个网站 - https://www.kroger.com/pl/chicken/05002。在 chrome 网络选项卡中,我看到如下请求,产品的详细信息很好地列为 JSON

enter image description here

我将 cURL 复制为 bash 并将其作为原始文本导入 Postman。它一直运行,没有任何反应。然后我使用了拦截功能,它仍然永远运行。

enter image description here

当两个请求完全相同时,为什么它在 Chrome 中运行而不是在 Postman 中运行?我错过了什么?感谢任何帮助,提前致谢。

1 个答案:

答案 0 :(得分:1)

这可能是因为他们不想让你做你想做的事。请注意 URL 中的“filter.verified”参数。

您可能想尝试与他们联系以获得外部 API 令牌 - 特别是如果您正在创建应用程序或扩展程序以比较具有竞争力的价格与分发所述应用程序或扩展程序的意图 - 无论是为了经济补偿还是不是。

道德上有问题的解决方法(肯定需要改进 - 这只是您如何解决问题的一个例子......):

GET https://www.kroger.com/search?query=chicken&searchType=default_search&fulfillment=all
const html = cheerio(responseBody);

var results = [];

html.find('div[class="AutoGrid-cell min-w-0"] > div').each(function (i, e)
{
    results.push({
        "Item": e.children[e.children.length-3].children[0].children[0].children[0]["data"],
        "Price": e.children[e.children.length-4].children[0].attribs["value"]
    })
});

console.log(results);

Output

如果您无法从他们那里获得 API 令牌,这可能是实现您想要的目标的合法方式。