Automatically save web page's html source code

  • Thread starter Thread starter Bob Roberts
  • Start date Start date
B

Bob Roberts

Hi,
I'm trying to pull information on my fantasy football league directly from
the Yahoo web page into Excel.
I had a macro set up last year that did it with an Excel web query, but
something's not working this time around.

(It almost seems as if Yahoo has somehow completely disabled my ability to
pull info from this web page into Excel or Word; not even copying and
pasting by hand seems to work-- try it!
http://football.fantasysports.yahoo.com/f1/show?page=roster&lid=188763&mid=5
)

Anyway, back to my real question. I figure if I can get ahold of the html
source, then I can get what I need out of it. So what I'd like to do is use
Visual Basic to automate something like a Save As in Internet Explorer.
I just want to do whatever is easiest - if that's using VB to control IE
that'd be fine, or sending a direct request for the web page from within VB,
if VB can do that.

Any help would be appreciated.
 
Bob Roberts said:
Hi,
I'm trying to pull information on my fantasy football league directly from
the Yahoo web page into Excel.
I had a macro set up last year that did it with an Excel web query, but
something's not working this time around.

(It almost seems as if Yahoo has somehow completely disabled my ability to
pull info from this web page into Excel or Word; not even copying and
pasting by hand seems to work-- try it!
http://football.fantasysports.yahoo.com/f1/show?page=roster&lid=188763&mid=5
)

Worked fine for me, really .. table colors, formatting and whatnot..
Anyway, back to my real question. I figure if I can get ahold of the html
source, then I can get what I need out of it. So what I'd like to do is use
Visual Basic to automate something like a Save As in Internet Explorer.
I just want to do whatever is easiest - if that's using VB to control IE
that'd be fine, or sending a direct request for the web page from within VB,
if VB can do that.

Assuming by saying VB, you really mean VB and not VBA, you have at least
options:

- MS Internet Transfer Control and do an HTTP query to get the source
- MS Internet Controls (a little IE to put on the form) and open the
website so you can then use the DOM to obtain the source

The latter might be more convinient, since the control presents you with
a nice interface. The former is more of a nice challange if you have a bit
time :)

hth
 
Jakob Bieling said:
http://football.fantasysports.yahoo.com/f1/show?page=roster&lid=188763&mid=5

Worked fine for me, really .. table colors, formatting and whatnot..


Assuming by saying VB, you really mean VB and not VBA, you have at least
options:

- MS Internet Transfer Control and do an HTTP query to get the source
- MS Internet Controls (a little IE to put on the form) and open the
website so you can then use the DOM to obtain the source

The latter might be more convinient, since the control presents you with
a nice interface. The former is more of a nice challange if you have a bit
time :)

hth

Hi Jakob,
Thanks for your response. Actually, I did mean VBA, not VB. I think

The HTTP query sounds the cleanest, but I don't know if that's available in
VBA?
Going through IE would work fine-- do you know of any places that have
sample code? And what does DOM mean?


On the other hand, I've decided it's a bug in either IE (6) or Office (2000)
that's keeping me from getting at the data my old way. What versions are you
running?
After some debugging, I decided that the web page's use of /** blah blah **/
as comments in non-display sections of the HTML code is causing the problem.
When they're there, I get nothing when I copy from IE and paste into Excel,
but when I strip them out it pastes just fine. Weird.
 
Bob Roberts said:
ability
http://football.fantasysports.yahoo.com/f1/show?page=roster&lid=188763&mid=5

Hi Jakob,
Thanks for your response. Actually, I did mean VBA, not VB. I think

Then you have to look if and which controls you use. I do not know VBA
and its capabilities, though.
The HTTP query sounds the cleanest, but I don't know if that's available in
VBA?

If not and you cannot use the "embedded-IE" approach either, then you
could try to use raw Winsock. This only works if you can do calls to any
API. In this case you would need to access some functions inside the
ws_32.dll I think. The MSDN has quite a lot of docs about Winsock, and if
you still have trouble, I recommend asking in alt.winsock.programming.
Going through IE would work fine-- do you know of any places that have
sample code? And what does DOM mean?

DOM means Document Object Model
On the other hand, I've decided it's a bug in either IE (6) or Office (2000)
that's keeping me from getting at the data my old way. What versions are you
running?

I use IE6 also. SP1 though. And Office I use XP.

hth
 
Back
Top