2014-03-19 4 views
0

Meteor (https://github.com/tmeasday/meteor-cron)에 cron 작업 설정이 있습니다.Meteor JS : XML을 구문 분석하는 Cron 작업

var onetKeys = ["17-0000.00", 
      "27-0000.00", 
      "37-0000.00", 
      "13-0000.00", 
      "21-0000.00", 
      "15-0000.00", 
      "47-0000.00", 
      "25-0000.00", 
      "45-0000.00", 
      "35-0000.00", 
      "29-0000.00", 
      "49-0000.00", 
      "23-0000.00", 
      "19-0000.00", 
      "11-0000.00", 
      "43-0000.00", 
      "39-0000.00", 
      "51-0000.00", 
      "33-0000.00", 
      "41-0000.00", 
      "53-0000.00"]; 

console.log("[+] ==== Cron Jobs ===="); 

Meteor.startup(function(){ 

    cron = new Cron(); 

    cron.addJob(500, function(){ 

    var params = [], finalUrl; 

    $.each(onetKeys, function(i, onet){ 
     params.push("onet=" + onet); 
     params.push("cn=100"); 
     params.push("rs=1&re=500"); 
     finalUrl = params.join("&"); 

     Meteor.call('retrieveJobs', finalUrl, function(error, results){ 
     console.log('GOT JOBS'); 
     $('job', results.content).each(function(){ 
      var jvid = $(this).find('jvid').text(); 
      if(!Jobs.findOne({jvid: jvid})) { 
      options = {} 
      options.title = $(this).find('title').text(); 
      options.company = $(this).find('company').text(); 
      options.address = $(this).find('location').text(); 
      options.url = $(this).find('url').text(); 
      options.jvid = jvid; 
      options.dateacquired = $(this).find('dateacquired').text(); 
      var id = createJob(options); 
      console.log("Job Created: " + id); 
      } 
     }); 
     }); 
    }); 
    }) 
}) 

위의 코드는 클라이언트로 실행됩니다 project_root/cron.js에 있습니다

여기 내 코드입니다. 이것을 서버로 옮길 필요가 있지만, jQuery의 도움을받지 않고 XML을 처리하는 방법을 모르겠습니다 (슬프다, 알고있다). jQuery없이 JavaScript에서 XML을 구문 분석하는 좋은 예가 있습니까?

답변

관련 문제