Click here to Skip to main content
Licence 
First Posted 12 Jun 2002
Views 170,584
Downloads 3,299
Bookmarked 46 times

Get The HTML Source of Any Web Page

By Srinivas Chintakindi | 12 Jun 2002
This article shows how to get HTML source of any WebPage even if the website prevents viewing the source
4 votes, 21.1%
1

2
1 vote, 5.3%
3
5 votes, 26.3%
4
9 votes, 47.4%
5
3.78/5 - 24 votes
μ 3.69, σa 2.85 [?]

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 Durgesht0:56 30 Jun '10  
Questionretrieve html Content of a secure page using vb/excel macros PinmemberNithima0:52 6 May '10  
GeneralAuthentication PinmemberIyke20107:22 1 Apr '10  
GeneralTnx Pinmemberyassine0071:02 26 Jun '08  
GeneralThanks PinmemberMember 45072755:40 30 Mar '08  
GeneralThanks a lot. Need some more Guidance & Help PinmemberTrupti Mehta22:46 23 Jul '07  
GeneralGet HTML Source of any URL PinmemberA.Dh.Kishore Kumaar23:33 23 Mar '06  
GeneralPls Help me Emergently PinmemberAlexDa1:19 13 Mar '06  
GeneralPls Help me Emergently PinmemberAlexDa1:17 13 Mar '06  
Generali need to get html source of web page in asp.net Pinmemberkellyllp18:07 10 Mar '04  
Generalget selected text of an html page Pinsussreshmaahmed229:06 15 Dec '03  
GeneralRe: get selected text of an html page Pinmemberempty1233:12 15 Jun '07  
Questionhow can i read UTF-8 Characters? PinsussTogrim23:08 1 Jul '03  
AnswerRe: how can i read UTF-8 Characters? PinsussBjarki14:38 20 Dec '03  
GeneralWell.. PinmemberPhilip Patrick4:28 13 Jun '02  
GeneralRe: Well.. PinmemberMatthew Ellis7:42 13 Jun '02  
GeneralRe: Well.. PinmemberDanPetitt10:26 17 Jun '02  
GeneralRe: Well.. PinmemberPhilippe Lhoste1:00 24 Jun '02  
GeneralRe: Well.. PinmemberAnthony_Yio20:32 9 Mar '03  
GeneralRe: Well.. Pinmemberpeppeddu20:07 6 Mar '04  
GeneralRe: Well.. Pinmemberluvskennychesney18:23 28 Oct '04  
GeneralRe: Well.. Pinmembergeblack7: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.120210.1 | Last Updated 13 Jun 2002
Article Copyright 2002 by Srinivas Chintakindi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid