我正在使用VBA(请参阅下面的代码)进行网络搜索,以获取某些加密货币的价格。什么时候手动进入数据选项卡,然后从网页点击它工作正常,但当我在宏中做它我只回来“请等待......” 页面显示“请稍候...”,因为它加载,宏假定这是整个页面。 我一直在寻找一种让宏等待整页加载而无法找到任何东西的方法。
任何帮助将不胜感激。
谢谢
With ActiveSheet.QueryTables.Add(connection:="URL;https://btc-e.com", _
Destination:=Range("$A$1"))
.Name = "btc-e"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False ' was 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 ' True ' was false
.WebDisableRedirections = False 'True ' was false
.Refresh BackgroundQuery:=False
End With
答案 0 :(得分:0)
您必须选择要删除的页面的特定表格或区域,否则将无效。原因是您会自动从您尝试抓取的页面转发到您实际可以抓取的页面。
当我选择刮取卖单时,这是我从宏录制器获得的代码:
With ActiveSheet.QueryTables.Add(Connection:="URL;https://btc-e.com", _
Destination:=Range("$B$2"))
.Name = "btc-e"
.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 = "3"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
正如您所看到的,它选择了属性“.WebTables”来选择网站的特定部分。您可以通过激活宏录制器,通过正常方式抓取它,选择所需区域,然后在生成的代码中查看WebTables的值来选择所需的部分。
希望这有帮助!