如何在scrapy spider中的两种解析方法之间传递数据?

时间:2018-07-13 02:33:45

标签: python scrapy web-crawler

在默认的parse()中,我抓取了一些数据,并像这样产生它们:

{
    'title': title,
    'author': author,
    'date': date,
    'raw_url': raw_url,
    'download_url': download_url,
    'redirect_url': redirect_url,
}

在另一种解析方法中,我需要使用download_url并抓取redirect_url,最终产生如下结果:

$(document).ready(function(){
  $('#myBtn').click(function(){
    let rolls = $("#rolls").val();
    console.log(rolls);    
    $('#myModal').show();
    var machine1 = $('#machine1').slotMachine();
    var machine2 = $('#machine2').slotMachine();
    var machine3 = $('#machine3').slotMachine();
    var machine4 = $('#machine4').slotMachine();
    var machine5 = $('#machine5').slotMachine();

    var arrResult = [];
  
    setTimeout(function(){
      machine1.shuffle(10, onComplete);
      machine2.shuffle(15, onComplete);
      machine3.shuffle(20, onComplete);
      machine4.shuffle(25, onComplete);
      machine5.shuffle(30, onComplete);
    }, 500);

    function onComplete(active){
      arrResult.push(this.active);
      if (arrResult.length === 5) {
        var output = arrResult.join('');
        console.log(output);
        rolls--;
        arrResult = [];
    
        $('table > tbody').append('<tr><td>'+ output +'</td></tr>');
    
        if(rolls > 0){
          setTimeout(function(){ 
            machine1.shuffle(10, onComplete);
            machine2.shuffle(15, onComplete);
            machine3.shuffle(20, onComplete);
            machine4.shuffle(25, onComplete);
            machine5.shuffle(30, onComplete);
          }, 1500);
        }
      }
    }
  });
  $('.close').click(function(){
    $('.modal').hide();
    $('table tbody tr').remove();
  });
});

如何将前一个字典传递给后一种方法并产生它们?

0 个答案:

没有答案