How to delay the execution of async traversal?

  node.js, question

Used in node, async; is installed with npm;
I’ll talk about the process first. I’ll first go through and get a url array.

http://w/page/1
 http://w/page/2
 http://w/page/3
 http://w/page/4

After traversing this array, each url will generate another array.

[http://w/998.html,
 http://w/997.html,
 http://w/996.html,
 http://w/995.html,
 http://w/994.html,
 http://w/993.html,
 http://w/992.html,
 http://w/991.html,
 http://w/990.html,
 http://w/989.html]  ...

And then traverse each url in that array
Let me describe it in pseudo code

for (var i = 1;   i < 3;  I plus)
 Ihx.push('http://w/page/' plus i);
 bracket
 self.ihx(ihx);
 
 ihx: function (arr) {
 var self = this;
 async.each(arr, function (item, callback) {
 setTimeout(function () {
 console.log(item)
 self.core(item, function ($) {
 var $itemlist = $('.post-listing .item-list');
 var linkList = $itemlist.map(function (idx, element) {
 var $element = $(element).find('.post-title a');
 return $element.attr('href');
 }).get();
 Log ("linkList = = =" plus linklist ")
 async.each(linkList, function (item, callback2) {
 setTimeout(function () {
 self.core(item, function ($) {
 var author = $('.post-inner .entry').find('p').eq(0).text();
 var content = $.html('.article_text');
 var text = $('.post-inner span[itemprop="name"]').text();
 Log ("text =" plus text ");
 if (!  !  text) {
 var thor = new articlema({
 title: text,
 author: author,
 category: '002',
 content: content
 });
 thor.save(function (err, thor) {
 if (err) return console.log(err);
 //console.log(thor);
 });
 
 bracket
 });
 }, 2000)
 
 
 }, function (err) {
 Log ("content = = = = = = = = = = = = = = = = =" plus err ");
 });
 
 })
 }, 1000)
 }, function (err) {
 Log ("item = = = = = = = = = = = = = = = = =" plus err ");
 })
 bracket

This did not reach my desired result console.log(linkList), which is the url captured by the page/2 page printed first, and the time did not slow down. besides, the inside will only be circulated after the outside circulation is finished. how should I change this

You should not use async.each but use async.eachSeries to control it.

In addition, if you use node, I suggest abandoning async and replacing it with generator plus promise. After all, node.js is 5.0, so it’s not too strange to have ES6.
First define several help functions

'use strict';
const next = (gen,val) => {
     const n = gen.next(val);
     !n.done && Promise.resolve(n.value).then(d=>next(gen,d));
 }
const run = genfunc => next(genfunc());
const sleep = time=>new Promise(resolve=>setTimeout(resolve,time));

Then rewrite your business logic, noting that asynchronous parts should be wrapped in Promise

'use strict';
 run(function* (){
 let arr = [];
 for (var i = 1;   i < 3;  I plus)
 Constitem = yieldgeturl ('http://w/page/'plus i);
 let $ = yield core(item);
 const $itemlist = $('.post-listing .item-list');
 const linkList = $itemlist.map(function (idx, element) {
 const $element = $(element).find('.post-title a');
 return $element.attr('href');
 }).get();
 Log ("linkList = = =" plus linklist ")
 arr.concat(linkList);
 bracket
 for(let i =0;  j<arr.length;  I plus)
 yield sleep(2000);
 let $ = yield core(linkList[i]);
 const author = $('.post-inner .entry').find('p').eq(0).text();
 const content = $.html('.article_text');
 let text = $('.post-inner span[itemprop="name"]').text();
 Log ("text =" plus text ");
 if(!  text)continue;
 const thor = new articlema({
 title: text,
 author: author,
 category: '002',
 content: content
 });
 yield thor.save().exec();
 bracket
 })

Do you think this is a clearer business logic?