View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default getting the source code of a web page

On Oct 6, 8:52*pm, Southern at Heart
wrote:
I need to get the source code of a web page and asign it to a string, where I
can search out the specific data I'm needing from the page. *(a web query of
the page gives me most of the data I need, but it doesn't give me the google
map on that page, and the gps coordinates which I need in my sheet) *If I
open the page in IE, view the source, I can programmatically filter out the
coordinates. *
So, my question: *How to get the source saved to a string in vba
thanks.


If you are repetitively interrogating a website, then capturing the
source code using the "GET" construction shown below can be used to
ones advantage. This method assigns the source code to a variable
(my_var in the construction shown below). In a subsequent step the
variable can be parsed for the desired data. This method is typically
much faster than opening IE and extracting the same information. I
have a macro that collects data on over 700 real estate addresses
found at a website. The macro takes over an hour when I run it
through IE, but only 14 minutes when I use the GET method...Ron

Sub Test()
my_url = "http://www.google.com"
Set my_obj = CreateObject("MSXML2.XMLHTTP")
my_obj.Open "GET", my_url, False
my_obj.send
my_var = my_obj.responsetext
Set my_obj = Nothing
End Sub