Close

Retrieving how many active cameras through browser

Having trouble with Sighthound Video? Post here for help.

Moderator: Staff

no avatar
mrmisi
 
Posts: 12
Joined: Tue Apr 22, 2014 9:55 am

Retrieving how many active cameras through browser

by mrmisi » Mon Nov 16, 2015 9:39 am

Hey there.
I'm trying to retrieve how many active cameras (parsing "liveCameraCount" and "totalCameraCount") are running using this python script:

Code: Select all
from bs4 import BeautifulSoup
import urllib
import urllib2
import base64

url = "my.pc.ip.address:port"
username = "user"
password = "pass"

handle = urllib2.Request(url)
authheader =  "Basic %s" % base64.encodestring('%s:%s' % (username, password))

data = urllib.urlopen(url)
soup = BeautifulSoup(data, "html.parser")

cameras = soup.findAll('span')
for span in cameras:
    print span.string


however, when it run it reply with:

None
None
ON

While it should be:

2
2
ON

Looking at the code:
Image

Do you know why?

no avatar
dev
 
Posts: 4
Joined: Thu Sep 03, 2015 12:31 pm

Re: Retrieving how many active cameras through browser

by dev » Mon Nov 16, 2015 8:03 pm

The values for liveCameraCount and totalCameraCount are filled in by Javascript.

Take a look in all_cameras_control.js around lines 63 and 64:
Code: Select all
    $("#liveCameraCount").text(actualEnabledCameraCount);
    $("#totalCameraCount").text(liveCameras.length);

The values for "liveCameraCount" and "totalCameraCount" are blank until this javascript runs.


Return to Technical Support
cron