Getting the entire HTML source code from a web page

Chinnick

New Member
Joined
Sep 9, 2009
Messages
12
I am looking to read the source code for a website that keeps the stats for a hockey league in Sweden

For other sites i can use the code below and it works fine, but the site i am using to get the Sweden stats seem to keep the data in some type of a Java app (sorry still somewhat of a newbie) and doesn't work the same as the others

when i veiw the source code just by right clicking the page all the data i want shows up. When i try to use my code it doesn't get the stuff i want.

I have tried both objDoc.body.innerHTML and objDoc.body.outerHTML and i get different results but not the same as right clicking on the page and viewing the source, is there another command that i can use to get it all?

the website is
HTML:
http://estat.hockeyligan.se/c/LPlayersPoints.aspx?LId=195&NumberOfRows=all


Code:
Sub Get_Stats()
Const strURIpre As String = "http://estat.hockeyligan.se/c/LPlayersPoints.aspx?LId=195&NumberOfRows=all"
Set ie = CreateObject("internetexplorer.application")
ie.Navigate strURIpre
Do
If ie.ReadyState = 4 Then
ie.Visible = False
Exit Do
Else
DoEvents
End If
Loop
Set objDoc = ie.Document
Stop
strMyPage = objDoc.body.innerHTML
ie.Quit
Set objDoc = Nothing
Set ie = Nothing
End Sub

Thanks in advance
 
I'm afraid that doesn't quitey help without seeing the rest of the code.:)

ie.document probably refers to the main document in IE.

It will include the frame but not the document within the frame.

It being a JSP page might not be a problem, a lot of the time these are just used to render the HTML you see.

There is more than likely something going on server side but usually what's happening is requests are being sent to the server and data being received back.

Try getting a collection of all the frames on the main document like this.
Code:
Dim doc As Object
Dim colFrms As Object
Dim objFrm As Object
 
        Set doc = ie.document
 
        Set colFrms.GetElementsByTagName("FRAME")
 
        For Each objFrm in colFrms
              Debug.print objFrm.innerHTML
        Next objFrm
Note this code is kind of a shot in the dark - without seeing the actual page it's pretty hard to help with this stuff.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Your code crashes on the line Set colFrms.GetElementsByTagName("FRAME"). Does the variable doc do anthing? I posted the code below only changing the URL.

PHP:
Private Sub CommandRun_Click()
    Dim wwwAdd As String
    wwwAdd = "https://www.google.com"
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.Navigate wwwAdd
    Do While ie.busy
        DoEvents
    Loop
    Dim doc As Object
    Dim colFrms As Object
    Dim objFrm As Object
 
        Set doc = ie.Document
 
        Set colFrms.GetElementsByTagName("FRAME")
 
        For Each objFrm In colFrms
              MsgBox objFrm.innerHTML
        Next objFrm
End Sub
 
Upvote 0
That's a typo - I told you it was a shot in the dark, I actually had my eye closed.
Code:
Set colFrms = doc.GetElementsByTagName("FRAME")
doc is just a variable for a reference to ie.Document - saves typing for one thing.

Oh, and the code won't really work with Google - they don't seem to use frames.:)
 
Upvote 0
Thanks for your help. I ran the code you gave me and it ran but didn't return anything in the loop. I'm not sure if your code isn't working or if it is something with this site. It looks like it has multiple frames with different frames opening different JSP pages.

If I right click on the frame I get the cas_ELContent.jsp link I want to pull from. This is dynamically created when I visit the site so I can't just pull down that URL.
 
Upvote 0
Are you sure it's actually frames you are dealing with?

Perhaps it's IFRAMES?

If there's a link on the page with a URL it could be somewhere in the HTML for the main page.

So you should be able to get the URL or even click the link, which might be what you need to do anyway.
 
Upvote 0
To start you could try changing to FRAME to IFRAME in the code I posted.

If you still get no luck with that perhaps you should see if the frame has an ID or Name attribute.
 
Upvote 0
I can't really help further without more information.

The only thing I can perhaps suggest is you try looking at some of the other properties for an IFRAME.

Perhaps something like source without the vowels.

PS I understand you can't post the URL, but it really is hard to help without it.:)
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top