0

我对 VBS 很陌生,但我需要从网页中提取属性信息并将信息输入到 Excel 中。我要做的是从链接、文本字段、按钮、图像等中获取对象信息。我需要的信息是每个项目的 .name、.id、.title、.value、.type、.class页面并为每个项目一起显示,即:从谷歌搜索页面搜索框是 .id: lst-ib, .name: q .title: Search .type: text 然后谷歌按钮是 .name: btnK .type : submit .value: Google Search 等。任何帮助都会非常有帮助!

4

1 回答 1

0

我建议为此目的使用另一种语言,例如 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>
于 2013-04-29T07:30:06.613 回答