'CYTOLOGY2 Yahooニューストピックス一括表示 20130126 '--------------------------------------------------------------- Imports System.Drawing Imports System.Windows.Forms Public Class AddIn Private Const APPNAME As String = "Yahooニューストピックス一括表示" Private tabb As TabBrowser Private std As Std Private ddLabelNow As ToolStripLabel Public Sub New() tabb = New TabBrowser() std = New Std() End Sub Public Sub AddIn_Load() startMessage() End Sub Public Sub AddIn_Stop() std.AddInMenuRemove() End Sub Public Sub AddIn_Start() ddButtonInitial01() demo1() End Sub Private Sub info(ByVal str As String, ByVal c As Color) If std.StopFlag Then Exit Sub ddLabelNow.Text = str ddLabelNow.ForeColor = c Application.DoEvents() End Sub Private Sub ddButtonInitial01() ddLabelNow = New ToolStripLabel("停止中") ddLabelNow.ForeColor = Color.Black std.AddInMenuAddOnce(ddLabelNow) End Sub Private Sub startMessage() tabb.TabText = APPNAME Dim str As String = "" str &= "<!doctype html><html lang=""ja""><head><meta charset=""utf-8""><title>" & APPNAME & "</title></head>" str &= "<body>" str &= "<h2>" & APPNAME & "</h2>" str &= "このデモンストレーションは、以下の動作をします<br>" str &= "1.Yahooトップページ表示<br>" str &= "2.ニュースのトピックス8件を取得<br>" str &= "3.8件を新規タブで開く<br>" str &= "4.アドインプログラムの実行を停止します<br>" str &= "<br>" str &= "実行ボタンで開始します" str &= "</body></html>" tabb.WebBrowser.DocumentText = str End Sub Private Sub demo1() tabb.Navigate("http://yahoo.co.jp/") tabb.DocumentCompletedEventAdd(AddressOf demo2) End Sub Private Sub demo2(ByVal sender As Object, ByVal e As System.EventArgs) tabb.DocumentCompletedEventRemove(AddressOf demo2) Dim elems As HtmlElementCollection = tabb.WebBrowser.Document.GetElementById("topicsfb").All Dim c As Integer = 0 For Each elm As HtmlElement In elems If elm.OuterHtml.StartsWith("<A") Then c += 1 tabb.TabAdd() tabb.Navigate(elm.GetAttribute("href")) info("トピックス " & c.ToString, Color.Blue) If c >= 8 Then Exit For End If End If Next std.ExitAddIn() End Sub End Class
このページのQRコード
便利ウェブサイト
便利 Android アプリ
便利 iOS(iPhone,iPad) アプリ