你可以嘗試直接從DOM
獲取文本數據
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "https://www.microsoft.com"
Do Until .ReadyState = 4
Wscript.Sleep 100
Loop
For Each Tag In .Document.GetElementsByTagName("script")
Tag.OuterHtml = ""
Next
For Each Tag In .Document.GetElementsByTagName("noscript")
Tag.OuterHtml = ""
Next
Content = .Document.GetElementsByTagName("body")(0).InnerText
Do While InStr(Content, vbCrLf & vbCrLf)
Content = Replace(Content, vbCrLf & vbCrLf, vbCrLf)
Loop
ShowInNotepad Content
.Quit
End With
Sub ShowInNotepad(Content)
With CreateObject("Scripting.FileSystemObject")
TempPath = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%TEMP%") & "\" & .GetTempName
With .CreateTextFile(TempPath, True, True)
.WriteLine (Content)
.Close
End With
CreateObject("WScript.Shell").Run "notepad.exe " & TempPath, 1, True
.DeleteFile (TempPath)
End With
End Sub
[這](http://stackoverflow.com/questions/11780366/vb-script-or-vba-code-to-copy-the-contents-of-a-web-webpage-to-a-word-excel-shee) –
問題在於網頁我想收集使用JavaScript來呈現數據的數據,因此下載頁面的源代碼將不起作用,因爲它不包含該數據。這就是爲什麼我要選擇全部複製nd粘貼 – Zulake
VBScript不是這種自動化的正確工具。改用類似[AutoIt](http://www.autoitscript.com/site/autoit/)的東西。 –