View Source of a Website

All Internet browsers allow users to view the HTML or other source code of any of the web pages they visit. For example, a user can view the code used to generate page source of website. Here in this tutorial, we will make a program that can view the source of a website. So, now let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add two TextBoxes named TextBox1 for inputting a URL from the site, and TextBox2 for viewing the page source of the site. Add a WebBrowser named WebBrowser1 to display the site. Add also two Buttons named Button1 for displaying the URL for the website and Button2 for viewing the source of the website. Design your layout like this one below: design 3. Put this code to your code module:
  1. Public Class Form1
  2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.         WebBrowser1.Navigate(TextBox1.Text)
  4.     End Sub
  5.  
  6.  
  7.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  8.         TextBox2.Text = WebBrowser1.DocumentText
  9.     End Sub
  10. End Class

Explanation:

We have code for Button1 for displaying the inputted website in the TextBox1 and displayed into the web browser. WebBrowser1.Navigate(TextBox1.Text) - is a syntax to for navigating the inputted URL in textbox1 and will display in the web browser. We also code for Button2_Click to view the page source coming from the WebBrowser1 to the TextBox2. DocumentText class is a method for viewing the page source of a website in the WebBrowser.

Output:

output output Download the source code below and try it! :) For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz

Add new comment