我有几个JSON源代码的页面。
const results = [];
await page.on('response', async (response) => {
if (response.url() ){
console.log('XHR response received');
console.log(await response.json()); //如何从response.json()采集数据并传给results数组?
}
});
console.info(results); 发布于 2019-10-16 16:24:31
如果我没理解错的话,您可以在数组内部收集响应:
const results = [];
await page.on('response', async (response) => {
if (response.url() && response.status() == 200){
console.log('XHR response received');
results.push(await response.json());
}
});
await page.goto(url, {waitUntil : 'networkidle0'});
console.log(results);https://stackoverflow.com/questions/58408266
复制相似问题