On the following webpage I'd like to get all the titles of youtube videos in my listbox1
Dim webRequest As WebRequest = webRequest.Create("https://www.youtube.com/results?q=test")
Dim webresponse As WebResponse = webRequest.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(webresponse.GetResponseStream())
Dim youtube As String = sr.ReadToEnd
Dim r As New System.Text.RegularExpressions.Regex("title="".*""")
Dim matches As MatchCollection = r.Matches(youtube)
For Each itemcode As Match In matches
ListBox1.Items.Add(itemcode.Value.Split("""").GetValue(1))
However with this code I get the titles but also a bunch of other stuff...
YouTube provides an API which might be a better way to get this information. The specific call you want to make is documented here: https://developers.google.com/youtube/v3/docs/search/list.
In order to use the YouTube API you will need to create an API key. This can be done from the Google developers console. Once you have a key then you can make calls to YouTube to search videos, get video information etc
Using your code as the basis you could use something along these lines:
The
q
parameter specifies the search query. This will get the first 50 matches to your search and put them in your drop down list.