YasserKhalil
Well-known Member
- Joined
- Jun 24, 2010
- Messages
- 844
Hello
I am trying to extract the urls from specific page ...
I got error at this line
I am trying to extract the urls from specific page ...
Code:
Sub Test() Dim xmlPage As New MSXML2.XMLHTTP60
Dim htmlDoc As New MSHTML.HTMLDocument
Dim htmlResults As MSHTML.IHTMLElementCollection
Dim htmlResult As MSHTML.IHTMLElement
Dim strUrl As String
Dim ws As Worksheet
Dim r As Long
r = 2
Set ws = Sheets("Sheet1")
Application.ScreenUpdating = False
xmlPage.Open "GET", "http://plants.newgarden.com/12190005/Catalog", False
xmlPage.send
If xmlPage.Status <> 200 Then
MsgBox "Problem" & vbNewLine & xmlPage.Status & " - " & xmlPage.statusText
Exit Sub
End If
htmlDoc.body.innerHTML = xmlPage.responseText
Set htmlResults = htmlDoc.getElementsByClassName("CCPageText")
For Each htmlResult In htmlResults
If InStr(htmlResult.innerHTML, "href") > 0 Then
Debug.Print htmlResult.innerHTML
strUrl = htmlResult.getAttribute("href")
End If
Next htmlResult
Application.ScreenUpdating = True
End Sub
I got error at this line
Code:
strUrl = htmlResult.getAttribute("href")