Link to home
Start Free TrialLog in
Avatar of snookie
snookie

asked on

WebBrowser DOM <link> problem

Hi all,

I'm going through the tags with this code:

For i = 0 To WebBrowser1.Document.All.length - 1
            'Insert Images into tblImages
            If WebBrowser1.Document.All(i).Tagname = "IMG" Then
                strSQL = "INSERT INTO tblImages (URL,SRC,ALT,Width,Height) VALUES ('" & Text1.Text & "','" & WebBrowser1.Document.All(i).src & "','" & Replace(WebBrowser1.Document.All(i).alt, "'", "''") & "'," & WebBrowser1.Document.All(i).Width & "," & WebBrowser1.Document.All(i).Height & ")"
                rs.CommandText = strSQL
                rs.Execute
            End If
        Next

I can get it to extract the <title> and <meta> tag info but soon as it hits the <link> tag it dies..

Does anyone have any ideas, please?
Avatar of schworak
schworak

Can you give me an example URL where the above code fails? I am testing it and it is working just fine for me.
Avatar of snookie

ASKER

hi ya,

thanks for reading. Following caused problems:

http://www.nikmakris.com/

note the two <link> in http://www.nikmakris.com/

my version of IE is 5.5 and I'm running Win2000 with SP2

http://www.yahoo.com/

is causing problem when a try and get the links with:

'Insert Hyperlinks into tblHyperlinks
            If (WebBrowser1.Document.All(i).Tagname = "A") Or (WebBrowser1.Document.All(i).Tagname = "a") Then
                If WebBrowser1.Document.All(i).Href <> "" Then
                strSQL = "INSERT INTO tblHyperLinks (URL,HREF,AnchorText) VALUES ('" & Text1.Text & "','" & WebBrowser1.Document.All(i).Href & "','" & Replace(WebBrowser1.Document.All(i).innerHTML, "'", "''") & "')"
                rs.CommandText = strSQL
                rs.Execute
                End If
            End If
           
http://dmoz.org/ works fine though..

cheers,

snookie..
ASKER CERTIFIED SOLUTION
Avatar of schworak
schworak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am running IE6 by the way
Avatar of snookie

ASKER

Found it dude,

it was to do with the event on which the code ran.

I ran my code on:

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)

you ran yours on:

Private Sub Command2_Click()

maybe my code was crashing as it was loading stylesheet or something, strange but its fixed...

thanks for the time mate...
No problem, glad I could help. Funny how timing is everything in some cases.