initialize() { // 构建所有的爬虫 let requests = [{ url: "https://news.ycombinator.com/news" }]; this.setRequests(requests).setSpider( new TopicSpider().setChromeOption("120.55.83.19", null, 10 * 1000) ); }
// 初始化爬虫 initialize() { // 构建所有的爬虫 let requests = [{ url: 'https://jsonplaceholder.typicode.com/posts' }]; this.setRequests(requests) .setSpider(new PostsSpider()) .transform(posts => { if (!Array.isArray(posts)) { throw new Error('爬虫连接失败!'); } return posts.map(post => { return `https://jsonplaceholder.typicode.com/comments/${post.id}`; }); }) .setSpider(new CommentsSpider()); }