运行此代码时,我不确定,但是滑雪板和product_id显然是值形式。
我想要:
value =“ BTdtb4CBz3uSJ2qv”
value =“ adi-ss20-042”
但是我得到“未定义”
class TresBien {
async scrapeRaffleInfo() {
// scrape the form_key and sku values
const response = await axios(
"https://tres-bien.com/adidas-yeezy-boost-380-mist-fx9764-ss20"
);
console.log("response: ", response);
const html = await response.data;
const $ = cheerio.load(html);
const res = $('input[name="sku"]').val();
const ans = $('input[name="form_key"]').val();
console.log(res && ans);
}
}
const main = async () => {
const tb = new TresBien(
"https://tres-bien.com/adidas-yeezy-700-v3-alvah-h67799-ss20"
);
let checkoutSucc = await tb.scrapeRaffleInfo();
if (checkoutSucc) {
Logger.logEventSuccess("Raffle successfully entered");
}
};
main();
答案 0 :(得分:1)
您的代码中有些错误:
scrapeRaffleInfo()
返回未定义,而您正在尝试在checkoutSucc
中使用它axios
库方法(例如:get()
,post()
,put()
,delete()
)。通常您需要axios.get()
,但是在代码中,您只是在使用axios()