2013-04-25 43 views
0

我對VBS很新,但我需要從網頁中提取屬性信息並將信息輸入到excel。我想要做的是從鏈接,文本字段,按鈕,圖像等獲取對象信息。我需要的信息是每個項目的.name,.id,.title,.value,.type,.class該頁面並顯示在一起爲每個項目,即:從谷歌搜索頁面搜索框是.id:lst-ib,.name:q .title:搜索.type:text然後谷歌按鈕是.name:btnK .type :提交。價值:谷歌搜索等等任何幫助將是非常有益的!從使用vbs的網頁提取並寫入excel

回答

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> 
相關問題