Mark Weerasinghe Mark Weerasinghe - 1 month ago 20
Vb.net Question

(VB.net) Web Scrapping Issue

Would like some help with a small issue i can't figure out

I simply need to display this in a Richtext box instead of a MsgBox, But when i do i only get one line of text (in this case only the first sentence)

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


^^^^ This doesn't work,Any help much appreciated.

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

Answer

Don't you have to;

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

Because you are replacing the new line each time.

And I really think this is a bad question, you didn't do any research nor 'undressing' the problem (go to the core of the problem and leave other code around it). Nobody else is going to benefit from this question, and the title doesn't match the problem

Comments