VB6 WebBrowser 元件 如何取得網頁段落原始碼

VB6 WebBrowser 元件 如何取得網頁段落原始碼

http://pastebin.com/zvHyWRPa

網頁原始碼如上

如何找出 /view/item-1104504-qwert.html 這段原始碼文字

/view/item-XXXX-XXXX.html XXX 都代表是變數,每次開啟時都會改變

如何找出這段文字然後顯現在文字方塊裡面

麻煩各位大大幫解答....感恩

Update:

感謝,解決我的問題了...

1 Answer

Rating
  • 世賢
    Lv 7
    8 years ago
    Favorite Answer

    '專案>設定引用元件>Microsoft Internet Controls

    '專案>設定引用項目>Microsoft HTML Object Library

    Option Explicit

    Private Sub Command1_Click()

    Dim WebDocument As HTMLDocument

    Dim taga As IHTMLElementCollection

    Dim i As Long

    Text1.Text = ""

    Set WebDocument = WebBrowser1.Document

    Set taga = WebDocument.getElementsByTagName("a")

    For i = 0 To taga.length - 1

    If taga(i).innerText = "qwert" Then

    Text1.Text = Text1.Text & taga(i).href & vbCrLf

    End If

    Next

    End Sub

    Private Sub Form_Load()

    WebBrowser1.Navigate "http://網址/"

    End Sub

    Source(s): VB6 and Me
Still have questions? Get your answers by asking now.