Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var request = require('request');
  2. var cheerio = require('cheerio');
  3. var options = {
  4.   uri: 'http://192.168.1.170/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion',
  5.   auth: {
  6.     user: 'admin',
  7.     pass: 'superpass',
  8.     sendImmediately: false
  9.   }
  10. };
  11. var arr=[] ;
  12. setInterval(function () {
  13.  
  14. request(options, function(error, response, body){
  15.     if (!error && response.statusCode == 200){
  16.     var newBody = body.toString('utf8');      
  17.     var $page = cheerio.load(newBody);
  18.     var cam = $page('body').text();
  19.     var arr = cam.split('\n');
  20.     if (arr[0] == 'channels[0]=1') {
  21.     console.log('Сработал вирт датчик движения камерой 1');
  22.     }
  23.     if (arr[2] == 'channels[2]=1') {
  24.     console.log('Сработал вирт датчик движения 2');
  25.     }
  26.     if (arr[3] == 'channels[3]=1') {
  27.     console.log('Сработал вирт датчик движения камерой 3');
  28.     }
  29.     if (arr[4] == 'channels[4]=1')
  30.     {
  31.     console.log('Сработал вирт датчик движения у 4');
  32.     }
  33.     if (arr[8] == 'channels[8]=1')
  34.     {
  35.     console.log('Сработал вирт датчик движения у 4');
  36.     }    
  37.     }
  38.     else{
  39.         console.log('Code : ' + response.statusCode)
  40.         console.log('error : ' + error)
  41.         console.log('body : ' + body)
  42.         }
  43. });}, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement