2016-10-12 101 views
-1

想一些幫助,一個小問題我想不通(VB.net)網絡刮痧問題

我只是需要在富文本框,而不是一個MsgBox來顯示這一點,但是,當我只做我得到一行文本(在這種情況下只有第一句)

For each node in nodes 
    richtextbox3.text = node.innertext 
next 

^^^^這不起作用,任何幫助非常感謝。

Private Sub Scrape() 
    Dim req As WebRequest = WebRequest.Create("http://www.metrolyrics.com/closer-lyrics-the-chainsmokers.html") 
    Dim doc As New HtmlDocument() 
    Using res As WebResponse = req.GetResponse() 
     doc.Load(res.GetResponseStream()) 
    End Using 

    Dim nodes = doc.DocumentNode.SelectNodes("//p[@class='verse']") 
    If nodes IsNot Nothing Then 
     For Each node In nodes 
      MsgBox(node.InnerText) 
     Next 
    End If 
End Sub 

回答

2

難道你不需要;

For each node in nodes 
    richtextbox3.text += node.innertext 
next 

因爲您每次都更換新行。

我真的認爲這是一個糟糕的問題,你沒有做任何研究,也沒有「解決」問題(去解決問題的核心問題,並在其周圍留下其他代碼)。沒有人會從這個問題中受益,並且標題與問題不匹配

+0

非常感謝你!是的,我知道,但我只需要一個快速回答....你不知道我通過什麼來得到這個工作代碼。 –