从网页提取使用vbs和写入excel



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

我建议使用另一种语言,例如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>

最新更新