Question : How can I retrieve the HTML source from a web page at a certain URL?

I want to retrieve the HTML source from specific web pages so I can extract some information.  Is there some simple code I can use to pass the url and get the html back?

Answer : How can I retrieve the HTML source from a web page at a certain URL?

You can use the WebBrowser control. Insert one on your form (Insert - ActiveX Controls - MS Webbrowser), then use the .Navigate method like this:

Me.YourWBControl.Navigate "URL here"

Once you've navigated there, you can use the Document object of that control to get to the Body. You'll need a reference to the Microsoft HTML Object Library in order to do this:

Dim acx As WebBrowser
Dim doc As HTMLDocument

Set acx = Me.WebBrowser9.Object
Set doc = acx.Document

Debug.Print doc.Body.innerHTML

Set doc = Nothing
Set acx = Nothing

Note that you'd need to change the WebBrowser9 to match the name of your webbrowser control.
Random Solutions  
 
programming4us programming4us