从Web页面提取数据 - 使用VBA [英] Extract Data from a Web Page - using VBA
本文介绍了从Web页面提取数据 - 使用VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用VBA,我需要从网页提取数据 http:// emops。 tse.com.tw/t21/sii/t21sc03_2011_9_e.htm
Using VBA, I need to extract data from webpage http://emops.tse.com.tw/t21/sii/t21sc03_2011_9_e.htm
我可以使用以下代码获取所有数据:
I am able to fetch all the data using following code:
With ActiveSheet.QueryTables.Add(Connection:="URL;http://emops.tse.com.tw/t21/sii/t21sc03_2012_2_e.htm", Destination:=Range("$A$1"))
.Name = "67083361_zpid"
.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
End With
但问题是我不希望整个页面的数据。 我想从工业名称为Electron的表格中获取数据(这是本例中的最后一个表格)
But the problem is I don't want data from whole page. I want data from the table where Industry name is Electron (It is the last table in this case)
有什么技巧吗?
推荐答案
更改:
.WebSelectionType = xlEntirePage to .WebSelectionType = xlSpecifiedTables
添加:
.WebTables = "2" below .WebFormatting = xlWebFormattingNone
'您必须使用2的试用和错误找到您想要抓住的确切表格
'You will have to use trial and error with the "2" to find the exact table you are wanting to grab
这篇关于从Web页面提取数据 - 使用VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文