I use the VBA below to scrape 250 URLs that I have listed in a column on a sheet named "URLs" from a site (all identical, except with different company data). But they instituted some traffic management limit service (Cloudfront?) that will block access to the entire domain (from my IP, at least) after ~150 URLs, after which I need to wait 3-5 minutes before I can access any URL on the domain again.
My workaround was to just split my 250 URLs into 2 buckets of 125, copy the 1st 125 into the URL column, run VBA > wait 5 minutes > copy 2nd group of 125 into the URL column > run VBA. But to reduce # of clicks, how can I keep all 250 URLs into the source URL column, but just insert a 5 minute wait/pause after the code loops through the first 125?
My workaround was to just split my 250 URLs into 2 buckets of 125, copy the 1st 125 into the URL column, run VBA > wait 5 minutes > copy 2nd group of 125 into the URL column > run VBA. But to reduce # of clicks, how can I keep all 250 URLs into the source URL column, but just insert a 5 minute wait/pause after the code loops through the first 125?
VBA Code:
Sub Loop_through()
Dim h1 As Worksheet, h2 As Worksheet
Dim u1 As Long, u2 As Long
Dim MyUrl As String
'
Range("quote_all_import_cols").ClearContents
Range(Range("wiperange").Value).ClearContents
Application.ScreenUpdating = False
Application.StatusBar = False
Set h1 = Sheets("URLs") 'origin
Set h2 = Sheets("Quotes") 'destiny
'
u1 = h1.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To u1
MyUrl = h1.Cells(i, "A").Value
Application.StatusBar = "import data : " & i - 1 & " of : " & u1 - 1
u2 = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
With h2.QueryTables.Add(Connection:="URL;" & MyUrl, Destination:=h2.Range("A" & u2))
.Name = "quotes.php?symbol=X"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "1"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
u3 = h2.Range("A" & Rows.Count).End(xlUp).Row
h2.Range("P" & u2 & ":P" & u3).Value = MyUrl
Next
Application.StatusBar = False
Application.ScreenUpdating = True
Application.CutCopyMode = False
MsgBox "End"
End Sub