Tuesday, 9 May 2017

I can write file in js array

I don't know how to write file when t set condition, code below:

  $('a.txt_link').each(function(){
     var link = $(this).attr("href"); 
     news.push(link);  
  })
  console.log(news);
  for(var i=0; i<news.length; i++)
  {
      // I set the condition that in the array if there is url as below it will write the file.
      if(news[i]=='http://vnexpress.net/tin-tuc/thoi-su/ha-noi-thi-diem-cho-buyt-thuong-di-vao-lan-buyt-nhanh-trong-6-thang-3581677.html ')
      {
          request(i).pipe(fs.createWriteStream('news/new'+ i +'.html'));
      }
  } 

} });



via Tiến Dũng

No comments:

Post a Comment