【问题标题】:Extracting from webpage using vbs and writing into excel使用vbs从网页中提取并写入excel
【发布时间】:2013-04-19 12:30:47
【问题描述】:
我对 VBS 很陌生,但我需要从网页中提取属性信息并将信息输入到 Excel 中。我想要做的是从链接、文本字段、按钮、图像等获取对象信息。我需要的信息是每个项目的 .name、.id、.title、.value、.type、.class页面并为每个项目一起显示,即:从谷歌搜索页面搜索框是 .id: lst-ib, .name: q .title: Search .type: text 然后谷歌按钮是 .name: btnK .type : submit .value: Google Search etc etc. 任何帮助都会非常有帮助!
【问题讨论】:
标签:
html
excel
web
properties
vbscript
【解决方案1】:
我建议为此目的使用另一种语言,例如 Ruby 非常擅长它,并且是 VbScripters 的自然升级。
也就是说,这是一种在 VbScript 中执行此操作的方法..
set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
with IE
.MenuBar = 0
.ToolBar = 0
.StatusBar = 0
.Visible = 1
.navigate "http://www.google.com"
end with
while IE.busy
wScript.sleep 400
wend
'html = IE.document.all.tags("html").item(0).outerhtml
wscript.echo IE.document.getElementsByTagName("font").item(0).innerText
wscript.echo "innerText:" & IE.document.all.tags("title").item(0).innerText
wscript.echo "innerHtml:" & IE.document.all.tags("title").item(0).innerHtml
wscript.echo "outerHtml:" & IE.document.all.tags("title").item(0).outerHtml
IE.quit
'gives
'Google.be aangeboden in: français Deutsch English
'innerText:Google
'innerHtml:Google
'outerHtml:<title>Google</title>