Website monitoring in vb? 
Author Message
 Website monitoring in vb?

Hi folks: Has anyone had experience with writing a website monitoring
program? I would like to ping (I can do that) and also grab html and test
it for a word, e.g., "error". I could grab the HTML with OpenUrl, but how
to parse? Also, I would like to test port 80 on the server.  Any ideas on
that? Thanks.

--
George Alliger
Director of Solutions
gOE, the group for organizational effectiveness, inc.

tel: (518) 355-9252
fax: (518) 464-4766
www.groupoe.com



Wed, 16 Oct 2002 03:00:00 GMT  
 Website monitoring in vb?
Hi George,

Perhaps you could set a timer to grab the html from a certain page (using
the Internet Transfer control or one of the better commercially available
controls/com objects), use Instr to get the position of a certain
never-changing part of the html. Then use Mid$ to see if the text you are
looking for is present before or after this never-changing html. Save what
it finds this time thru the loop into a static or global string and simply
compare it to what you find the next time thru the loop.
Here's a sub I once concoted in a program which does something along these
lines. In your case, say the word 'error' occurs was within the next 50
characters of html after the string 'Current Status'. You would set
m_NumChars to 50, BeforeAfter to 1(or just kill the whole 'BeforeAfter'
test), and m_IndexStr to "Current Status". Now anytime anything within the
html changes in those 50 chars following, it would make it through to the
'page is changed' comment. In there you could search to see if 'error' or
another condition occurred . If anything maybe this will help you bounce a
few ideas around to get it to do exactly what you'd like:

Private m_BeforeAfter% '0=compare before, 1=compare after the indexstr text
Private m_IndexStr$ 'static text to seek out
Private m_NumChars% 'number of characters before or after the indexstr to
compare for change

Public Sub ParseHTML(B As clsBrowSet, HTML As String)
    Dim IndexStrPos&
    Static OldIndex$
    Dim NewIndex$

    If Len(HTML) Then

        If m_BeforeAfter = 0 Then
            'search the specified # of chars BEFORE the Index String
            IndexStrPos = InStr(1, HTML, m_IndexStr, 1) ' holds starting
position of index string
            IndexStrPos = IIf((IndexStrPos - m_NumChars) < 1, 1,
IndexStrPos - m_NumChars) 'if negative, make it one
            NewIndex = Mid$(HTML, IndexStrPos, m_NumChars)
        Else
            'search the specified # of chars AFTER the Index String
            IndexStrPos = InStr(1, HTML, m_IndexStr, 1) + Len(m_IndexStr)
'holds ending position of index string
            NewIndex = Mid$(HTML, IndexStrPos, m_NumChars)
       End If

        'NewIndex now contains the string located NumChars before or after
the IndexStr
        'OldIndex contains the string from the last loop thru...
        'so compare them and if different, page has changed

        If NewIndex = OldIndex Then
            'page is same as last time...do something
        Else
            'page is changed...do something
        End If

       OldIndex = NewIndex    'stash for next loop through

    End If
End Sub

Regards,

Mike Pudelko

...please remove <spambotssuck> from email addy when responding via private
email.

Quote:
> Hi folks: Has anyone had experience with writing a website monitoring
> program? I would like to ping (I can do that) and also grab html and test
> it for a word, e.g., "error". I could grab the HTML with OpenUrl, but how
> to parse? Also, I would like to test port 80 on the server.  Any ideas on
> that? Thanks.

> --
> George Alliger
> Director of Solutions
> gOE, the group for organizational effectiveness, inc.

> tel: (518) 355-9252
> fax: (518) 464-4766
> www.groupoe.com



Thu, 17 Oct 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Comment on QB websites/view websites by comments .-=??=-.

2. Freebie Website and a free link to your Website

3. GUI programmed on 14inch monitor is different on 19inch Monitor

4. Performance Monitor , eh Monitor

5. Usinig 2 monitors: IDE problem on secondary monitor

6. Adding websites to link labels in VB.NET

7. Any good VB.NET websites?

8. Website using VB.NET

9. pinging websites via vb.net

10. VB.NET websites?

11. VB.Net websites

12. VB website

 

 
Powered by phpBB® Forum Software