在msgbox中获取网页文本

时间:2016-07-17 14:17:35

标签: internet-explorer vbscript com messagebox

我试图在我的代码发送后让msgbox出现。 我想显示内部文本。

到目前为止我已经

 ie = CreateObject("InternetExplorer.Application")
 ie.Navigate("http://www.webpage.com.au/")
 ie.Visible = True
 mesg = TextBox1.Text.ToString()
 pw = "....." ie.Document.All("password").Value = pw
 ie.Document.All("idpagers").Value = Id
 ie.Document.All("message").Value = mesg
 ie.Document.All("Send").Click()
 pID = ie.Document.All().ToString

 MessageBox.Show(pID)

但是这显示了 system.object.blah.blah

2 个答案:

答案 0 :(得分:0)

Do 
    wscript.sleep 50            
Loop Until ie.document.readystate = "complete"

把它放在导航之后。您必须等待页面加载。

这会将html文本分配给页面,然后提取纯文本。

Set ie = CreateObject("InternetExplorer.Application") 
ie.Visible = 0
ie.Silent = 1 
ie.Navigate2 "file://" & FilterPath & "Filter.html"
Do 
    wscript.sleep 50            

Loop Until ie.document.readystate = "complete"
ie.document.body.innerhtml = Inp.readall
Outp.write ie.document.body.innertext

答案 1 :(得分:0)

尝试使用此代码:

Const TriStateTrue = -1 ' Pour la prise en charge de l'Unicode
URL = InputBox("Entrez l'URL pour y extraire son Code Source HTML "&vbcr&vbcr&_
"Exemple ""http://www.google.fr""","Extraction du Code Source © Hackoo © 2013","http://www.google.fr")
If URL = "" Then WScript.Quit
Titre = "Extraction du Code Source de " & URL
Set ie = CreateObject("InternetExplorer.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
ie.Navigate(URL)
ie.Visible=false
DO WHILE ie.busy
LOOP
DataHTML = ie.document.documentElement.innerHTML
strFileHTML = "CodeSourceHTML.txt"
Set objHTMLFile = objFSO.OpenTextFile(strFileHTML, 2, True, TriStateTrue)
objHTMLFile.WriteLine(Titre&vbcrLF&String(120,"*"))
objHTMLFile.WriteLine(DataHTML)
objHTMLFile.Close
ie.Quit
Set ie=Nothing
wscript.echo DataHTML
 Ouvrir(strFileHTML)
wscript.Quit

Function Ouvrir(File)
    Set ws=CreateObject("wscript.shell")
    ws.run "Notepad.exe "& File,1,False
end Function