Get specefic items from tags on website
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts
Page 1 of 1
Im trying to create a tool where you just click a button and it will get you the info needed and add it to a listview
From this link: http://www.internet-radio.com/stations/hardcore/page1
Eg when the website loads it will get the name from the radio station and the wmp link and add it to a listview
Name
Anyone have a clue on how i could accomplish this ?
From this link: http://www.internet-radio.com/stations/hardcore/page1
Eg when the website loads it will get the name from the radio station and the wmp link and add it to a listview
Name
Dance Uk Stream Danceradiouk.ComThe link the button with the wmp logo goes to
http://servers.internet-radio.com/tools ... pls&t=.m3u

Anyone have a clue on how i could accomplish this ?
visualtech wrote:use RegExCan you give me an example ?
It is unlikely that regex by itself will give the needed functionality.
You can use a WebBrowser control to access the HTML elements.
This sample will list the link names/wmp links from the table on that page:
You can use a WebBrowser control to access the HTML elements.
This sample will list the link names/wmp links from the table on that page:
Code: Select all
Private Sub btnTest_Click(sender As System.Object, e As System.EventArgs) Handles btnTest.Click
WebBrowser1.ScriptErrorsSuppressed = True
WebBrowser1.Navigate("http://www.internet-radio.com/stations/hardcore/page1")
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If e.Url.ToString() = "http://www.internet-radio.com/stations/hardcore/page1" Then
Dim tables As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("table")
Dim rows As HtmlElementCollection = tables(0).GetElementsByTagName("tr")
For i As Integer = 0 To rows.Count - 1
Dim cells As HtmlElementCollection = rows(i).GetElementsByTagName("td")
Dim links As HtmlElementCollection = cells(0).GetElementsByTagName("a")
Dim href As String = links(1).GetAttribute("href")
Dim links2 As HtmlElementCollection = cells(1).GetElementsByTagName("a")
Dim title As String = links2(0).InnerText
ListView1.Items.Add(New ListViewItem(New String() {title, href}))
Next
End If
End Sub
mandai wrote:It is unlikely that regex by itself will give the needed functionality.Thanks this was excatly what i needed
You can use a WebBrowser control to access the HTML elements.
This sample will list the link names/wmp links from the table on that page:Code: Select allPrivate Sub btnTest_Click(sender As System.Object, e As System.EventArgs) Handles btnTest.Click WebBrowser1.ScriptErrorsSuppressed = True WebBrowser1.Navigate("http://www.internet-radio.com/stations/hardcore/page1") End Sub Private Sub WebBrowser1_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted If e.Url.ToString() = "http://www.internet-radio.com/stations/hardcore/page1" Then Dim tables As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("table") Dim rows As HtmlElementCollection = tables(0).GetElementsByTagName("tr") For i As Integer = 0 To rows.Count - 1 Dim cells As HtmlElementCollection = rows(i).GetElementsByTagName("td") Dim links As HtmlElementCollection = cells(0).GetElementsByTagName("a") Dim href As String = links(1).GetAttribute("href") Dim links2 As HtmlElementCollection = cells(1).GetElementsByTagName("a") Dim title As String = links2(0).InnerText ListView1.Items.Add(New ListViewItem(New String() {title, href})) Next End If End Sub
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023