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.
5 posts Page 1 of 1
Contributors
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

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
Dance Uk Stream Danceradiouk.Com
The link the button with the wmp logo goes to
http://servers.internet-radio.com/tools ... pls&t=.m3u
Image

Anyone have a clue on how i could accomplish this ?
https://t.me/pump_upp
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

use RegEx :)
Image
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

visualtech wrote:
use RegEx :)
Can you give me an example ?
https://t.me/pump_upp
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

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:
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
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

mandai wrote:
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:
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
Thanks this was excatly what i needed
https://t.me/pump_upp
5 posts Page 1 of 1
Return to “Coding Help & Support”