【发布时间】:2016-08-12 10:09:11
【问题描述】:
我正在尝试创建一个从web page 抓取和导入表格的宏, 更具体地说,我想得到两张桌子tables pointed by arrows, please ignore the text in the table if it doesn't make sense, I translated using google。这些表是自动更新的,所以我使用了 IE 方法(@ron),没有抓取任何数据。我很累,有人可以帮帮我吗?我是 vba 新手,感谢任何帮助。
Sub test()
' open IE, navigate to the website of interest and loop until fully loaded
Set IE = CreateObject("InternetExplorer.Application")
my_url = "http://www.neeq.com.cn/static/statisticdata.html"
With IE
.Visible = False
.navigate my_url
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not IE.busy And IE.ReadyState = 4
DoEvents
Loop
End With
Set tbl = IE.Document.getElementsByTagName("table")
For Each itm In tbl
i = 1
For Each itm2 In itm.Rows
For Each cell In itm2.Cells
ActiveSheet.Cells(i, 2) = cell.innerText
i = i + 1
Next
Next
Next
end sub()
【问题讨论】:
-
end sub() 不正确
-
抱歉,打错了。
标签: vba excel internet-explorer web-scraping