2016-07-17 5 views
1

私のコードが送信されたら、msgboxを表示しようとしています。 内部のテキストを表示したいと思います。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

+0

VBスクリプトは、申し訳ありませんが私が間違ってタグを追加参照 – shaggs

+0

問題は、ちょうどあなたが呼び出すオブジェクトの文字列表現を与える 'ToStringメソッド()'使用していますこれは 'System.Object'に対してです。代わりに' InnerHTML() 'と' innerText() 'を使って、DOM要素のHTML表現かテキスト表現だけを返します。 – Lankymart

+0

@Lankymart答えとして例を挙げてください。正しい場合には答えとしてマークすることができます – shaggs

答えて

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 
+0

私はこれを私の本当のものに似ているが、同じ結果に置いていた – shaggs

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 
関連する問題