タイトル | : Re^5: ソースの一部取得は? |
記事No | : 3124 |
投稿日 | : 2006/02/15(Wed) 19:24 |
投稿者 | : 魔界の仮面弁士 |
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("hhttp://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
|