Open In App

How to get HTML code from loaded WebView ?

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will know how to find the HTML code from the loaded Web view. HTML code is the structural block of code over which the whole webpage run. The loaded webpage is the result of the execution of that code block and which is executed by the web browser. The code block may contain HTML, CSS, javascript, etc. The HTML markup language is the pillar of the code block ( HTML code), CSS properties depict how it will appear & it’s styling, and javascript can be used for dynamic changes in webpages. Suppose, we visit a website, for instance, geekforgeeks.org, and we want to see its source code then there are two ways to get it:

  • Using inspect element
  • Using view page source

Let’s understand both approaches sequentially.

Using inspect element: We can inspect the webpage by the following steps, as given below:

Step 1: Visit your desired website like geeksforgeeks.org, in this case.

GeeksforGeeks webpage

Step 2: Right-click anywhere on the webpage, choose the inspect element.

Selecting the Inspect option

Step 3: You will get the source code for the required webpage. On hovering the specific code block, it will highlight the particular section for which the hovering over it. Also, if you want to see the specific code block for the highlighted portion then it will highlight only the particular portion in the source code.

Note: We can also use the keyboard shortcut to inspect elements by pressing the Ctrl + Shift + I key.

Using view page source: This method can be used to see the source code for specific web pages. Follow the steps, as given below:

Step 1: Visit your desired website like geekforgeeks.org.

GeeksforGeeks webpage

Step 2: Right-click anywhere on the webpage, choose View page source.

Select View page source option

Step 3: You will get the complete code of the webpage.

Note: We can use the keyboard shortcut to achieve the same by typing the Ctrl + U key.


Last Updated : 09 Mar, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads