esak2000
asked on
foxpro - using Shell.Explorer
I'm currently using the Shell.Explorer object to automate data extraction from the web.
The code that I found and changed slightly is below. I have a free foxpro form that loads a table and scans through the urls in a field and then call the code below as a seperate .prg to access the url.
I realize that there must be a more efficient way to load the class once or define the class in the url and then call the method in class for each url, but since I haven't worked much with Foxpro classes, I don't know how to do it. How can I load the class once in the form and call the method to access the html for each url in the table that I'm scanning?
I'm only interested in using "Shell.Explorer" object and no other programmable browser.
This is the code that is called in a file call AccessWeb.prg
This is the code within the form that I use to create the class and return the html of the web page that is sent to the class:
The code that I found and changed slightly is below. I have a free foxpro form that loads a table and scans through the urls in a field and then call the code below as a seperate .prg to access the url.
I realize that there must be a more efficient way to load the class once or define the class in the url and then call the method in class for each url, but since I haven't worked much with Foxpro classes, I don't know how to do it. How can I load the class once in the form and call the method to access the html for each url in the table that I'm scanning?
I'm only interested in using "Shell.Explorer" object and no other programmable browser.
This is the code that is called in a file call AccessWeb.prg
LPARAMETERS url
owb = createobject("WebBrowserForm")
owb.getinnerhtml("Opening web page",url)
DEFINE CLASS WebBrowserForm AS FORM
ADD OBJECT WebBrowser AS OLECONTROL WITH OLECLASS = "Shell.Explorer"
PROCEDURE GetInnerText
LPARAMETERS cMessage, cURL
LOCAL cHTML
IF EMPTY(cURL)
RETURN ''
ENDIF
WITH This.WebBrowser
.Navigate2(cURL)
DO WHILE .ReadyState <> 4 AND .ReadyState <> 3
ENDDO
ENDWITH
WAIT CLEAR
DO while VARTYPE(This.WebBrowser.Document.body) <> [O]
ENDDO
cHTML = This.WebBrowser.Document.All[0].outerhtml
SUSPEND
RETURN cHTML
PROCEDURE GetInnerHTML
LPARAMETERS cMessage, cURL
LOCAL cHTML
IF EMPTY(cURL)
RETURN ''
ENDIF
WITH This.WebBrowser
.Navigate2(cURL)
DO WHILE .ReadyState <> 4 AND .ReadyState <> 3
ENDDO
ENDWITH
WAIT CLEAR
DO while VARTYPE(This.WebBrowser.Document.body) <> [O]
ENDDO
cHTML = This.WebBrowser.Document.All[0].outerhtml
SUSPEND
RETURN cHTML
ENDDEFINE
This is the code within the form that I use to create the class and return the html of the web page that is sent to the class:
chtml = AccessWeb(UrlListings.URL)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome!
ASKER