Click here to Skip to main content
12,356,678 members (62,077 online)
Click here to Skip to main content
Add your own
alternative version

Stats

319.4K views
10.3K downloads
50 bookmarked
Posted

Get The HTML Source of Any Web Page

, 12 Jun 2002
Rate this:
Please Sign up or sign in to vote.
This article shows how to get HTML source of any WebPage even if the website prevents viewing the source
<!-- Download Links --> <!-- Add the rest of your HTML here -->

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

Share

About the Author

Srinivas Chintakindi
Web Developer
India India
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

You may also be interested in...

Comments and Discussions

 
QuestionHow can I use this to get the source of a page on screen (not url) Pin
AdamZacks30-Aug-13 0:40
memberAdamZacks30-Aug-13 0:40 
GeneralReading HTML source of target page Pin
Swapnil Durgesht29-Jun-10 23:56
memberSwapnil Durgesht29-Jun-10 23:56 
Questionretrieve html Content of a secure page using vb/excel macros Pin
Nithima5-May-10 23:52
memberNithima5-May-10 23:52 
GeneralAuthentication Pin
Iyke20101-Apr-10 6:22
memberIyke20101-Apr-10 6:22 
GeneralTnx Pin
yassine00726-Jun-08 0:02
memberyassine00726-Jun-08 0:02 
GeneralThanks Pin
Member 450727530-Mar-08 4:40
memberMember 450727530-Mar-08 4:40 
GeneralThanks a lot. Need some more Guidance & Help Pin
Trupti Mehta23-Jul-07 21:46
memberTrupti Mehta23-Jul-07 21:46 
GeneralGet HTML Source of any URL Pin
A.Dh.Kishore Kumaar23-Mar-06 22:33
memberA.Dh.Kishore Kumaar23-Mar-06 22:33 
GeneralPls Help me Emergently Pin
AlexDa13-Mar-06 0:19
memberAlexDa13-Mar-06 0:19 
GeneralPls Help me Emergently Pin
AlexDa13-Mar-06 0:17
memberAlexDa13-Mar-06 0:17 
Generali need to get html source of web page in asp.net Pin
kellyllp10-Mar-04 17:07
memberkellyllp10-Mar-04 17:07 
Generalget selected text of an html page Pin
reshmaahmed2215-Dec-03 8:06
sussreshmaahmed2215-Dec-03 8:06 
GeneralRe: get selected text of an html page Pin
empty12315-Jun-07 2:12
memberempty12315-Jun-07 2:12 
Questionhow can i read UTF-8 Characters? Pin
Togrim1-Jul-03 22:08
sussTogrim1-Jul-03 22:08 
AnswerRe: how can i read UTF-8 Characters? Pin
Bjarki20-Dec-03 13:38
sussBjarki20-Dec-03 13:38 
GeneralWell.. Pin
Philip Patrick13-Jun-02 3:28
memberPhilip Patrick13-Jun-02 3:28 
GeneralRe: Well.. Pin
Matthew Ellis13-Jun-02 6:42
memberMatthew Ellis13-Jun-02 6:42 
GeneralRe: Well.. Pin
DanPetitt17-Jun-02 9:26
memberDanPetitt17-Jun-02 9:26 
GeneralRe: Well.. Pin
Philippe Lhoste24-Jun-02 0:00
memberPhilippe Lhoste24-Jun-02 0:00 
GeneralRe: Well.. Pin
Anthony_Yio9-Mar-03 19:32
memberAnthony_Yio9-Mar-03 19:32 
GeneralRe: Well.. Pin
peppeddu6-Mar-04 19:07
memberpeppeddu6-Mar-04 19:07 
GeneralRe: Well.. Pin
luvskennychesney28-Oct-04 17:23
memberluvskennychesney28-Oct-04 17:23 
GeneralRe: Well.. Pin
geblack29-Jul-05 6:22
membergeblack29-Jul-05 6:22 

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

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

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