שתף באמצעות


How to Get a text / value from a website to a Textbox in Visual Basic 2008

Question

Tuesday, December 22, 2009 2:46 PM | 1 vote

**Hi Guys,
**

I have a problem:

**I want to get a value or a text from youtube here is an example: If lets say that i want to check my youtube views, ratings, comments how will i do it using a webbrowser control?
**

**I wanna know this because my program will use this information. ;D
**

Any Help is appreciated :)

 

 

 

Quick answer please :)

All replies (4)

Tuesday, December 22, 2009 8:41 PM ✅Answered | 2 votes

Drag a webbrowser, 2 buttons and 2 textboxes onto the form.

See this code, rest of things go in similar way:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate("http://www.youtube.com/watch?v=hksxtbcS780")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = WebBrowser1.Document.GetElementById("watch-view-count").InnerText
        TextBox2.Text = WebBrowser1.Document.GetElementById("defaultRatingMessage").InnerText
    End Sub

Press F5 button and test out above code.

Thanks

My BlogMy Facebook


Tuesday, December 22, 2009 3:07 PM | 1 vote

Quick Answer :

Load page in webbrowser component. Use Webbrowser.Document.getElementById(), Webbrowser.Document.getElementByTagName() methods to get HTML DOM objects. Use innerHTML and InnerText methods to get values.

Thanks

My BlogMy Facebook


Tuesday, December 22, 2009 3:32 PM | 1 vote

Thanks, But can you say how i will put in the value/Text into a textbox :)

Thanks for your time


Tuesday, December 22, 2009 10:03 PM | 1 vote

OMG Thank You so Much !