Import full source code to excel

willmarks

New Member
Joined
Oct 28, 2010
Messages
2
Hi all,

I'm fairly new at writing macros.
My main goal is to be able to import the "keywords" from the source code of a website to excel.

I found the following code which seems to import most of the source code;

Sub Demo()
Dim ie As Object
Dim sWholeFile As String
Dim asLineByLine() As String
Dim lLine As Long
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://www.longhead.com/"
Do While ie.Busy And Not ie.ReadyState = 4
DoEvents
Loop
sWholeFile = ie.Document.body.innerhtml
ie.Quit
Set ie = Nothing
asLineByLine = Split(sWholeFile, vbCrLf)
For lLine = LBound(asLineByLine) To UBound(asLineByLine)
Sheet1.Cells(lLine + 1, 1).Value = asLineByLine(lLine)
Next lLine
End Sub

The main problem with this however is that it doesn't import the part of the source code which normally includes the keywords.
Where in the code is it going wrong??

Many thanks.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Welcome to the board.

I'm not able to test but I wonder if the keywords are contained within the innerHTML property of the Title object, rather than the Body object?
 
Upvote 0
possibly, I was thinking that perhaps the 'body' was referring to the <body> part of the source code, however the keywords are in the <head> part. however simply switching the two over doesn't seem to fix the problem.
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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