Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the source code of a html page using VB.net?

I'm writing a program that gets the source code of a web page with a video on it. It then uses regular expressions to isolate the download link of that video. then it uses httpwebrequest and httpwebresponse to download the video. My problem arises when certain sites have a page where you have to click continue in order to get to the video page.

For example, there is a video playing on http://nextgenvidz.com/view/s995xvc9e2fv called "The.Matrix.Reloaded.2003.mp4" so I tell my program to get the source code for the url "http://nextgenvidz.com/view/s995xvc9e2fv" but it can't find the video's download link because it's searching for the file in the "continue" page's source code. If you go to that website above and view source, you won't see the link. Then, click continue and do the same when the video appears and you'll notice that the file is only there in the second one.

How can I get the source code for the page that the video is playing on, and not the page where I have to click continue?

I am trying to use this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim Loading As String = "Loading..."
    TextBox1.Text = Loading
    Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(TextBox2.Text)
    Dim response As System.Net.HttpWebResponse = request.GetResponse()

    Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

    Dim sourcecode As String = sr.ReadToEnd()
    TextBox1.Text = sourcecode
End Sub

Maybe there's a way to auto select the "Continue" button programmatically?

like image 328
daniel11 Avatar asked Apr 28 '11 11:04

daniel11


People also ask

How do I get the source code from HTML?

To view only the source code, press Ctrl + U on your computer's keyboard. Right-click a blank part of the web page and select View source from the pop-up menu that appears.

Where can I code vb net?

Microsoft Visual studio forms the most common type of IDE for VB.Net programming. To install Visual Studio use this guide. To write your code, you need to create a new project. On the new window, click Visual Basic from the left vertical navigation pane, and Choose Windows Forms Application.


1 Answers

This guy answered it very well.

How can I get HTML page source for websites in VB.NET?

This was his code:

Dim sourceString As String = New System.Net.WebClient().DownloadString("SomeWebPage")
like image 173
Stephen Avatar answered Oct 13 '22 23:10

Stephen