Can I parse through Web Page for specific data?

Version 1

    Verified Product Versions

    Wavelink Naurtech CETerm 5.7

    If you want to look for specific text on a web page so that you can take some action based upon its presence on that page, you will need to parse through the HTML. As an example, suppose you receive / are navigated to a web page that displays the text "SAPConsole Offline Page" in the page title, you may want to trigger a reconnection with the host application. In order to do so, you must have CETerm continually look for the specific text.

     

    CETerm provides an OnDocumentDone event which may be used. You can check the web page document in the OnDocumentDone event handler and re-navigate as needed. Here is a code snippet for the event handler. It looks for the text string "Offline" in the web page title:

     

    function OnDocumentDone( session )

    {

        // Get document object

        var d=CETerm.Session( session ).Browser.Document;

     

        // Compare title

        if ( d.title.match("Offline") )

        {  

            // Return to home URL or do whatever...

            var script = "CETerm.PostIDA( 'IDA_URL_HOME', " + session + " );"

            CETerm.SetTimeout( script, 500 );

        }

    }

    Note that this script uses a "deferred" navigate to the home URL. This allows the handler to exit before the new navigation. You could have also checked the RF strength before the navigation if that could have been the cause of the disconnect. You could also re-direct the user to a static page which would have instructions to return to coverage and reconnect.

     

    NOTE: The equivalent event handler for telnet emulation sessions is OnSessionReceive. This may be used to look for specific data received in emulation sessions. The OnDocumentDone event handler only applies to browser sessions. This event is triggered whenever a page finishes loading.

     

    Please review the CETerm Scripting Guide for more details.