Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var request = require('request');
- var cheerio = require('cheerio');
- var options = {
- uri: 'http://192.168.1.170/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion',
- auth: {
- user: 'admin',
- pass: 'superpass',
- sendImmediately: false
- }
- };
- var arr=[] ;
- setInterval(function () {
- request(options, function(error, response, body){
- if (!error && response.statusCode == 200){
- var newBody = body.toString('utf8');
- var $page = cheerio.load(newBody);
- var cam = $page('body').text();
- var arr = cam.split('\n');
- if (arr[0] == 'channels[0]=1') {
- console.log('Сработал вирт датчик движения камерой 1');
- }
- if (arr[2] == 'channels[2]=1') {
- console.log('Сработал вирт датчик движения 2');
- }
- if (arr[3] == 'channels[3]=1') {
- console.log('Сработал вирт датчик движения камерой 3');
- }
- if (arr[4] == 'channels[4]=1')
- {
- console.log('Сработал вирт датчик движения у 4');
- }
- if (arr[8] == 'channels[8]=1')
- {
- console.log('Сработал вирт датчик движения у 4');
- }
- }
- else{
- console.log('Code : ' + response.statusCode)
- console.log('error : ' + error)
- console.log('body : ' + body)
- }
- });}, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement