目前我想寫個取得股票的程式,用法是利用WebBrowser去抓取原始碼搜尋,想請教假如原始碼你想要的值剛好在<B>...</B>之間,各位都是如何去抓取中間的值呢??
程式如下
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = "http://www.hep-tech.com.tw/"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = Nothing
If TextBox1.Text <> String.Empty Then
Me.WebBrowser1.Navigate(TextBox1.Text)
End If
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
DisplayElem()
End Sub
Private Sub DisplayElem()
If (WebBrowser1.Document IsNot Nothing) Then
Dim Elems As HtmlElementCollection
Dim WebDoc As WebBrowser = WebBrowser1
Elems = WebDoc.Document.GetElementsByTagName("b")
Dim tmpStr As String = Nothing
For Each elem As HtmlElement In Elems
TextBox2.Text += (elem.InnerText) & vbNewLine
Next
End If
End Sub
End Class
作者已經移除這則留言。
回覆刪除作者已經移除這則留言。
回覆刪除請問如我要擷取的是如圖中的 URL 呢?
回覆刪除圖:http://hidetxt.com/hidden/76017023.png
原來回應中的程式碼會被去掉...與好用圖
mada O
回覆刪除那是幫你把文字轉圖檔的網站
我有試過用嵌入連結的方式
並不會被去掉
請你再試一下吧 ^^