- 日時: 2011/04/05 11:07
- 名前: 花ちゃん
- ***********************************************************************************
* カテゴリー:[インターネット][][] * * キーワード:通信,HTML,WEB,,, * ***********************************************************************************
元質問:ソースの一部取得は? - st 2006/02/15-13:28No.3117
WebBrowserで表示させて表示されたWebのソース(ちなみに取得したソースはテキストボックスに表示させています。)を、一部分だけとりだして他のテキストボックスに表示させたいのです。
----------------------------------------------------------------------------------- Re^5: ソースの一部取得は? - 魔界の仮面弁士 2006/02/15-19:24 No.3124 -----------------------------------------------------------------------------------
2003 だとすれば、こんな感じかな。
([プロジェクト]-[参照の追加]の画面にて、COM の "Microsoft HTML Object Library" を追加) ===================================================================================== Private Sub AxWebBrowser1_DocumentComplete( _ ByVal sender As Object, _ ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent _ ) Handles AxWebBrowser1.DocumentComplete
ListBox1.Items.Clear()
Dim Document As mshtml.HTMLDocument = _ DirectCast(AxWebBrowser1.Document, mshtml.HTMLDocument) Dim HtmlElements As mshtml.IHTMLElementCollection = Document.getElementsByTagName("A") For Each HtmlElement As mshtml.IHTMLElement In HtmlElements Dim Anchor As mshtml.IHTMLAnchorElement = _ DirectCast(HtmlElement, mshtml.IHTMLAnchorElement) If Anchor.href.StartsWith("http://rd.yahoo.co.jp/toppage/topics/") Then ListBox1.Items.Add(HtmlElement.innerText) End If ReleaseComObject(Anchor) Next ReleaseComObject(HtmlElements) ReleaseComObject(Document) End Sub
Private Sub ReleaseComObject(ByVal O As Object) If Not O Is Nothing AndAlso System.Runtime.InteropServices.Marshal.IsComObject(O) Then Dim I As Integer = System.Runtime.InteropServices.Marshal.ReleaseComObject(O) While I > 0 I = System.Runtime.InteropServices.Marshal.ReleaseComObject(O) End While End If End Sub
|