You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Got库爬取Advent of Code输入数据时遭遇400错误的问题求助

使用Got库爬取Advent of Code输入数据时遭遇400错误的问题求助

我正在尝试爬取Advent of Code的输入数据,为此写了这段代码:

import got from 'got';

(async () =>{

const url = 'https://adventofcode.com/2022/day/1/input'

try {

const response = await got.get(url);

console.log(response.body)

console.log(typeof(response.body))

} catch (error) {

console.log(error)

}

})();

但运行后却碰到了错误:HTTPError: Response code 400 (Bad Request)

这段代码请求其他URL时都能正常工作,而且我在浏览器里打开这个输入数据的链接,明明能看到内容。我实在搞不懂问题到底出在哪...

备注:内容来源于stack exchange,提问作者olivier

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 07:05:29