Click here to Skip to main content
Licence 
First Posted 12 Jun 2002
Views 178,452
Bookmarked 46 times

Get The HTML Source of Any Web Page

By | 12 Jun 2002 | Article
This article shows how to get HTML source of any WebPage even if the website prevents viewing the source

Introduction

Some Web Sites do not allow visitors to view the HTML source of their web pages. They can disable our right mouse button to prevent accessing the "view source" menu option and some other web sites open their pages in a special window which has no menu bar to select the "Source" option from "View" menu.

How to get and display the source code

I used the Microsoft XMLHTTP object in this sample application to get the source code of the web page. It simply makes a synchronous HTTP GET request and displays the response in the browser.

Why this code?

This type of application is already available on the CodeProject website in an article submitted by our friend Dhandapani Ammasai. The extra features in my application are that we can view the source code of any web page as well as saving the source code directly onto our desktop in any supported file format (txt,htm,html,doc etc).

Note: your browser should have javascript enabled in order to run this application.

XMLHTTP Object

To use the XMLHTTP object, we need to create an instance of it using Server.CreateObject("Microsoft.XMLHTTP"). We can then use the Open and Send methods to get the source code of the web page.

Installation

Copy the gethtmlsource.asp and savetodisk.asp files to the root directory (typically Inetpub/wwwroot). You must be running either Personal Web Server on your machine or have access to a web server that runs IIS.

Run the gethtmlsource.asp file in your browser.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Srinivas Chintakindi

Web Developer

India India

Member

Hi All, I am having around 6+ years of Software Development Experience completely in Microsoft Technologies. With the initial background of ASP,VB I have strengthened my skillset with DotNet and SharePoint Technologies. I do have passion for work in latest technologies

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralReading HTML source of target page PinmemberSwapnil Durgesht23:56 29 Jun '10  
Questionretrieve html Content of a secure page using vb/excel macros PinmemberNithima23:52 5 May '10  
GeneralAuthentication PinmemberIyke20106:22 1 Apr '10  
GeneralTnx Pinmemberyassine0070:02 26 Jun '08  
you probably dont know it but you saved me
GeneralThanks PinmemberMember 45072754:40 30 Mar '08  
GeneralThanks a lot. Need some more Guidance & Help PinmemberTrupti Mehta21:46 23 Jul '07  
GeneralGet HTML Source of any URL PinmemberA.Dh.Kishore Kumaar22:33 23 Mar '06  
GeneralPls Help me Emergently PinmemberAlexDa0:19 13 Mar '06  
GeneralPls Help me Emergently PinmemberAlexDa0:17 13 Mar '06  
Generali need to get html source of web page in asp.net Pinmemberkellyllp17:07 10 Mar '04  
Generalget selected text of an html page Pinsussreshmaahmed228:06 15 Dec '03  
GeneralRe: get selected text of an html page Pinmemberempty1232:12 15 Jun '07  
Questionhow can i read UTF-8 Characters? PinsussTogrim22:08 1 Jul '03  
AnswerRe: how can i read UTF-8 Characters? PinsussBjarki13:38 20 Dec '03  
GeneralWell.. PinmemberPhilip Patrick3:28 13 Jun '02  
GeneralRe: Well.. PinmemberMatthew Ellis6:42 13 Jun '02  
GeneralRe: Well.. PinmemberDanPetitt9:26 17 Jun '02  
GeneralRe: Well.. PinmemberPhilippe Lhoste0:00 24 Jun '02  
GeneralRe: Well.. PinmemberAnthony_Yio19:32 9 Mar '03  
GeneralRe: Well.. Pinmemberpeppeddu19:07 6 Mar '04  
GeneralRe: Well.. Pinmemberluvskennychesney17:23 28 Oct '04  
GeneralRe: Well.. Pinmembergeblack6:22 29 Jul '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120604.1 | Last Updated 13 Jun 2002
Article Copyright 2002 by Srinivas Chintakindi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid