打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
VBA访问网页获取数据
2015年11月02日 22:08:16 阅读数:11749 标签: vba访问网页 更多个人分类: VBA 开发
本文主要介绍VBA访问网页获取数据。
实现效果:将网页中表的数据输出到excel中。
VBA代码:
Sub getResource()
Columns("A:E").ClearContents
Set HTML = CreateObject("htmlfile")
With CreateObject("msxml2.xmlhttp")
URL = "http://data.eastmoney.com/stock/tradedetail.html"
.Open "get", URL, False
.send
HTML.body.innerhtml = StrConv(.responsebody, vbUnicode)
Cells(1, 2) = HTML.body.document.getElementById("notice_Ddl").DefaultValue
Set tr = HTML.all.tags("tr")
j = 1
For r = 0 To tr.Length - 1
If Val(tr(r).Cells(0).innertext) + 1 = j Then
j = j + 1
Cells(j, 1) = tr(r).Cells(0).innertext
Cells(j, 2) = tr(r).Cells(1).innertext
Cells(j, 3) = tr(r).Cells(2).innertext
Cells(j, 4) = tr(r).Cells(6).innertext
Cells(j, 5) = tr(r).Cells(8).innertext
End If
Next
End With
End Sub
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
VBA利用XMLHTTP抓取百度搜索数据结果并给出网页链接
网页数据采集 | VBA实例教程
用VBA操作网页并抓取数据
VBA移动单元格内容2移动数据
JS 无刷新排序
javascript 取table中内容
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服