C# と VB.NET の質問掲示板

わんくま同盟

ASP.NET、C++/CLI、Java 何でもどうぞ

C# と VB.NET の入門サイト


(過去ログ 126 を表示中)
■74991 / )  javascriptで生成されるhtmlを取得したい
□投稿者/ ホゲ (1回)-(2015/02/16(Mon) 16:05:31)

分類:[.NET 全般] 

VB.NETを使用しています。
javascriptで生成されるhtmlを確実に取得できる方法を探しています。

IEから特定のページのコンテンツを取得するプログラムを作成しています。
そのページのHtmlコードとコンテンツはJavascriptから生成されています。
連続でプログラムを動かすと、コンテンツを取得できる時、出来ない時があります。
ページの読み込み完了はDocumentCompleteイベントで判断しています。

知恵をお貸しください。よろしくお願いいたします。

Public Class Form1
Dim WithEvents IE As SHDocVw.InternetExplorer
Dim ihtml As mshtml.IHTMLElement = Nothing

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
IE = New SHDocVw.InternetExplorer
IE.Visible = True
IE.Navigate("http://www.test.com")

Dim ihtml As mshtml.IHTMLElement = Nothing
ihtml = dhtml.GetElementById("hoge") '★IDのhogeはあるが、コンテンツが空のことがあります。

End Sub
Private Sub IE_DocumentComplete(pDisp As Object, ByRef URL As Object) Handles IE.DocumentComplete
ihtml = DirectCast(pDisp.Document, mshtml.IHTMLDocument)
End Sub
End Class
返信 編集キー/


管理者用

- Child Tree -