Click here to Skip to main content
16,022,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone, I want to write a small program to help me to detect the live streaming URL or .m3u8 URL from any website. but it face on problem with using webclient as the code below.

please help me to verify and correct it.

thanks

What I have tried:

Imports System.Net
Imports System.Text.RegularExpressions

Public Class Form1

    Private Sub btbClick_Click(sender As Object, e As EventArgs) Handles btbClick.Click

        Dim textUrl As String = txtURL.Text

        Try
            Dim webClients As New WebClient()

            Dim pageContents As String = webClients.DownloadString(textUrl)
            LabelT.Text = "Page content fetched successfull."

            Dim patTerns As String = "(http[s]?://[^\s]*\.m3u8)"
            Dim reGexs As New Regex(patTerns, RegexOptions.IgnoreCase)
            Dim matChes As MatchCollection = reGexs.Matches(pageContents)

            If matChes.Count > 0 Then
                LabelT.Text = ".m3u8 links found."

                For Each matchs As Match In matChes
                    lstOut.Items.Add(matchs.Value)
                Next
            Else
                LabelT.Text = ".m3u8 links not found."
            End If

        Catch ex As Exception
            LabelT.Text = "Error fetching or processing page content:" & ex.Message
        End Try

    End Sub

End Class
Posted

1 solution

We can't help - a quick check using Expresso says that your regex works (or at least here). It matched both
Text"
http://hello.m3u8
http://goodbye.m3u8
perfectly.

So it's probably the data you are feeding it. Use the debugger to check the contents of both textURL and pageContents (heck, write them to a file and use an editor if you don't know how to use a debugger) and make sure that the file contains the text you are looking for.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900