ActiveMISC     More ActiveX Products... Site Home

ActiveMISC --- WebWalker Interface


The WebWalker interface download a web page and returns a html document handle. You can use this handle to retrieve the Web page elements.

Methods
Sample Code

Search Failure on google and display the first 5 pages. You should use "cscript.exe" to run the codes --- with "wscript.exe", WScript.Echo displays a dialog box.

// Display titles of the search results
function print(doc)
{
var ps=doc.all.tags("P");
var n=ps.length;
for(var i=0; i<n; i++)
    {
    if(ps[i].className.toLowerCase()!="g")
        continue;
    var subs=ps[i].children;
    if(subs.length<1)
        continue;
    if(subs[0].tagName.toLowerCase()!="a")
        continue;
    WScript.Echo(subs[0].innerText);
    }
}

// Find the [Next] button URL
function getNext(doc)
{
var imgs=doc.all.tags("img");
var n=imgs.length;
for(var i=0; i<n; i++)
    {
    if(imgs[i].src.toLowerCase().indexOf("nav_next.gif")>=0)
        {
        var a=imgs[i].parentElement;
        if(a==null)
            return("");
        if(a.tagName.toLowerCase()!="a")
            return("");
        return(a.href);
        }
    }
return("");
    }

// Programm starts here
var wk=new ActiveXObject("ActiveMISC.WebWalker");
var c=0;
var url="http://www.google.com/search?hl=en&ie=ISO-8859-1&q=failure";
while(c<5 && url.length>0)
    {
    doc=wk.OpenURL(url);
    if(doc==null)
        break;
    print(doc);
    url=getNext(doc);
    c++;
    }