拉/刮具有多个结果页面VBA的数据

我试图在Excel中创build一个macros,以便我可以从一个有多个结果页面的网站上刮取数据。 我似乎无法弄清楚。 我只能得到从第一页显示的信息,但作为重复,因为我试图编码它去到下一页。 这就是为什么我得到的结果复制。 这是我迄今为止的代码。

Sub QueryDelinquency() Dim nextrow As Integer, i As Integer Application.ScreenUpdating = False Application.DisplayStatusBar = True For i = 1 To 5 'this is the page range to be captured. Application.StatusBar = "Processing Page " & i nextrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1 With ActiveSheet.QueryTables.Add(Connection:= _ "URL;https://www.myfloridalicense.com/delinquency_results.asp?SID=&page=&i &county_1=AL&status=NS&send_date=12/11/2015&search_1.x=1" & i, _ Destination:=Range("A" & nextrow)) .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlSpecifiedTables .WebFormatting = xlWebFormattingNone .WebTables = "10" .WebPreFormattedTextToColumns = False .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With ThisWorkbook.Save Next i = i + 1 Application.StatusBar = False End Sub 

我想要它把所有的数据。 在我知道的网站上这个特定的search有超过60个结果页面。 任何帮助将不胜感激。 假设这个search结果中有100个页面。 如果有一种方法可以使页面中的页面继续计数,直到到达数据的末尾,那就是我正在寻找的东西。

尝试:

  With ActiveSheet.QueryTables.Add(Connection:= _ "URL;https://www.myfloridalicense.com/delinquency_results.asp?SID=&page=" & i & "&county_1=AL&status=NS&send_date=12/11/2015&search_1.x=1", _ Destination:=Range("A" & nextrow)) 

那么它看起来像每个网页使用几乎完全相同的url,只是页=&我改变到page = 2&,page = 3&,等等,所以你可以使用计数器递增的URL和循环遍历所有的网页直到没有任何遗漏,或者点击右箭头button进入下一页,并在html中find它:

 <a href="pleaseWait_Portal.asp?redirectto=delinquency_results.asp&amp;SID=&amp;county_1=&amp;status=NS&amp;send_date=12/11/2015&amp;page=4&amp;search_1.x=1"><img src="portal/images/singlearrowrightbutton.gif" border="0" alt="Next"></a> 

此外,请确保您创build一个datevariables来replaceURL中的date,否则你会一直在同一天重复。