To: PowerObject@yahoogroups.com From: "Michael Talley" Date: Fri, 20 Sep 2002 06:40:58 -0700 (PDT) Subject: [PowerObject] OLE Webpage Automation ------------------------------------------------------ Some of you may already know how to do this, but I thought I'd share for the ones that don't. First a little background. I've written an NFL Power Rankings application for my own amusement and to refine some techniques that were getting rusty in a couple of areas. At first I created an entry screen to enter the data from the NFL.com website for each game. But being a good programmer I knew I'd be too lazy to do this every week so I saved a sample webpage locally as a file and wrote a parser to pull out the information I wanted. But I also knew I was too lazy to save down the webpage for every game, every week so I wrote an OLE automation routine to go and read the info directly from the webpage. NFL.com uses a predictably nomenclature to name their files every week so it was easy to incorporate it into my program. The script below is a test to make sure it was operating as desired. I used a window with a multi-line edit control and a command button. I put the script in the command button and simply "Ran" the window, I didn't even make an application out of it. Here's the code: -----------------Begin Code Snippet---------------- // Webpage Snagger // by Michael Talley OLEObject IE long ll_status String s_html IE = CREATE OLEObject ll_status = IE.ConnectToNewObject("InternetExplorer.Application") // Make this happen in the background IE.Visible = FALSE // Set the website IE.Navigate("http://www.nfl.com/gamecenter/gamebook/NFL_20020915_JAC@KC") // Wait until we have loaded the entire webpage before continuing DO While IE.ReadyState <> 4 LOOP // Get the HTML s_html = String(IE.Document.Body.innerHTML) // Stick it into an MLE control mle_1.Text = s_html IE.Quit() DESTROY IE -----------------End Code Snippet------------------- If this is useful to anybody, it's yours. It comes without warranty or liability and absolutely NO tech support. ;-) Regards, Mike Talley