FoxPro Program For Extracting HTML - GetHtml

Another little program released. This program is for retrieving the HTML of a web page.

After experimenting with the West Wind Internet and Client Tools and then with my own version of a wininet.dll wrapper, I decided the easiest way was to use the WinHTTP service. I didn’t even know it existed until I found it on Calvin Hsia’s Weblog.

Below is the main code of the application. Look at the links provided in the readme for more information on the oHTTP object instantiated in the code.

Thisform.MousePointer = 11
Try
        Local oHTTP As "winhttp.winhttprequest.5.1"
        oHTTP=Newobject("winhttp.winhttprequest.5.1")
        oHTTP.Open("GET",Trim(Thisform.txtUrl.Value),.F.)
        oHTTP.Option(4) = 13056 && Ignore ssl errors
        && Lets look like IE
        oHTTP.SetRequestHeader("user-agent", ;
                "Mozilla/4.0 (compatible; MSIE 6.0; Windows ;
                NT 5.2; .NET CLR 1.0.3705;)"
)

        oHTTP.Send()

        Thisform.txtHtml.Value = oHTTP.ResponseText
        Thisform.txtHeaders.Value = oHTTP.GetAllResponseHeaders
Catch To ex
        Thisform.txtHtml.Value = ex.Message
Finally
        Thisform.MousePointer = 0
Endtry

Click here to download the Windows 2000sp3 and up installer (5.2Mb)
Latest version 1.0.47

Post a Comment

Your email is never shared. Required fields are marked *

*
*