就像我用下面的代码刮了 3 页:
var Xray = require('x-ray');
var x = Xray();
x('https://blog.ycombinator.com/', '.post', [{
title: 'h1 a',
link: '.article-title@href'
}])
.paginate('.nav-previous a@href')
.limit(3)
.write('results.json')
我如何报告进度?
我尝试了 .then() 但似乎不起作用。
x('https://blog.ycombinator.com/', '.post', [{
title: 'h1 a',
link: '.article-title@href'
}])
.paginate('.nav-previous a@href')
.limit(3)
.write('results.json')
.then(
//something to report the progression
)
或同样不起作用的回调函数
x('https://blog.ycombinator.com/', '.post', [{
title: 'h1 a',
link: '.article-title@href'
}])(()=>{
//something to report the progress
})
.paginate('.nav-previous a@href')
.limit(3)
.write('results.json')