VBA scrapping code permission denied error

时间:2017-06-15 10:08:34

标签: excel vba excel-vba web-scraping

I was trying to scrap some data from a website using VBA. i have written following code. Sometimes it opens the final page and sometimes it does not. When it opens the final Page, it throws an error saying "Permission denied". Code is as following:

Sub hullByAshish()
Dim html As HTMLDocument
Dim ElementCol As Object
Dim Link As Object
Dim appIE As Object
Dim a As String
Dim i As Long
Dim objElement As Object
Dim objCollection As Object
Set appIE = CreateObject("internetexplorer.application")
a = "ASDETA"
With appIE
    .Navigate "https://www.marinetraffic.com/en/ais/index/search/all/keyword:" & a
    .Visible = True
End With
Do While appIE.Busy
    DoEvents
Loop
Set html = appIE.document
Set ElementCol = html.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "ASDETA" Then
'MsgBox "yahoo"
Link.Click
End If
Next Link
End Sub

0 个答案:

没有答案