# This is the URL that streams alerts such as motion detection. Documentation at goo.gl/S38ZQq my($url) = "http://".$user.":".$password."@".$ip.":".$port."/ISAPI/Event/notification/alertStream"; #start an instance of SAX parser for each monitor my $handler = SAXAlertStreamHandler->new(); my $parser = XML::Parser::PerlSAX->new( Handler => $handler ); my %parser_args = (Source => {SystemId => $url}); $parser->parse(%parser_args); exit; Couldn't open http://user:password@10.1.10.23:80/ISAPI/Event/notification/alertStream: No such file or directory at /usr/local/share/perl/5.18.2/XML/Parser/PerlSAX.pm line 146. #### #!/usr/bin/perl use XML::Twig; use warnings; use strict; use LWP; my $url = 'http://username:password@10.0.0.1/Event/notification/alertStream'; my $browser = LWP::UserAgent->new(); my $twig = new XML::Twig( twig_handlers => { EventNotificationAlert => \&AlertStreamHandler } ); my $response = $browser->get( $url, ':content_cb' => \&raw_handler, ':read_size_hint' => 1024, ); sub raw_handler { my ( $data, $response ) = @_; unless ( $data =~ /^--boundary/ ) { $twig->parse($data); #print $data; } } sub AlertStreamHandler { my ( $twig, $eventAlert ) = @_; my $ip = $eventAlert->first_child('ipAddress')->text; my $eventType = $eventAlert->first_child('eventType')->text; print "IP: " . $ip . "\n"; print "Event: " . $eventType . "\n"; $twig->purge; # delete the twig so far. Not sure if this is needed. }