从网站错误中提取数据

Sub GetDataFromLandings() Dim lastrow As Long, x As Long Application.ScreenUpdating = False ActiveWorkbook.Sheets("Sheet2").Range("A2:F250") = Null With Worksheets("Sheet2") lastrow = .Range("G" & Rows.Count).End(xlUp).Row For x = 2 To lastrow RequeryLandings .Cells(x, "G") Next End With Application.ScreenUpdating = True End Sub Sub RequeryLandings(address As String) Dim ws As Worksheet Dim NewRow As Long With Worksheets("Sheet2") Set ws = ActiveWorkbook.Sheets("Sheet1") With ws.QueryTables.Add(Connection:= _ "URL;https://www.flightradar24.com/data/aircraft/" & address, _ Destination:=ws.Range("$A$1")) .Name = "NNum_Results.aspx?NNumbertxt=22NA" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False DoEvents 

以上代码从网站获取数据https://www.flightradar24.com/data/aircraft/

并通过取自列G的不同值循环:

 RequeryLandings .Cells(x, "G") 

所以URL地址就是这种forms

 "URL;https://www.flightradar24.com/data/aircraft/" & address, 

其中&地址是来自列G的值。

如果G列中的第一行是SP-LRC,那么它将searchURL

 "URL;https://www.flightradar24.com/data/aircraft/SP-LRC" 

我正试图从不同的网站获取数据

http://www.airliners.net/search?registrationActual=SP-LRC&display=detail

我不知道代码应该如何改变,以适应该地址…在这种情况下, SP-LRC不是在地址的末尾,而是在&display=detail

这个string

 http://www.airliners.net/search?registrationActual=SP-LRC&display=detail 

可以写成

 "http://www.airliners.net/search?registrationActual=" & "SP-LRC" & "&display=detail" 

所以改变

 "URL;https://www.flightradar24.com/data/aircraft/" & address 

 "URL;http://www.airliners.net/search?registrationActual=" & address & "&display=detail"