Click here to Skip to main content
5,790,650 members and growing! (19,087 online)
Email Password   helpLost your password?
Web Development » ASP » General     Intermediate

Get The HTML Source of Any Web Page

By Srinivas Chintakindi

This article shows how to get HTML source of any WebPage even if the website prevents viewing the source
NT4, Win2K, WinXP, Windows, ASP, Dev

Posted: 12 Jun 2002
Updated: 12 Jun 2002
Views: 96,771
Bookmarked: 35 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
22 votes for this Article.
Popularity: 4.85 Rating: 3.62 out of 5
4 votes, 23.5%
1
0 votes, 0.0%
2
1 vote, 5.9%
3
4 votes, 23.5%
4
8 votes, 47.1%
5

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


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
Occupation: Web Developer
Location: India India

Other popular ASP articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 19 of 19 (Total in Forum: 19) (Refresh)FirstPrevNext
GeneralTnxmemberyassine0071:02 26 Jun '08  
GeneralThanksmemberMember 45072755:40 30 Mar '08  
GeneralThanks a lot. Need some more Guidance & HelpmemberTrupti Mehta22:46 23 Jul '07  
GeneralGet HTML Source of any URLmemberA.Dh.Kishore Kumaar23:33 23 Mar '06  
GeneralPls Help me EmergentlymemberAlexDa1:19 13 Mar '06  
GeneralPls Help me EmergentlymemberAlexDa1:17 13 Mar '06  
Generali need to get html source of web page in asp.netmemberkellyllp18:07 10 Mar '04  
Generalget selected text of an html pagesussreshmaahmed229:06 15 Dec '03  
GeneralRe: get selected text of an html pagememberempty1233:12 15 Jun '07  
Generalhow can i read UTF-8 Characters?sussTogrim23:08 1 Jul '03  
GeneralRe: how can i read UTF-8 Characters?sussBjarki14:38 20 Dec '03  
GeneralWell..memberPhilip Patrick4:28 13 Jun '02  
GeneralRe: Well..memberMatthew Ellis7:42 13 Jun '02  
GeneralRe: Well..memberDanPetitt10:26 17 Jun '02  
GeneralRe: Well..memberPhilippe Lhoste1:00 24 Jun '02  
GeneralRe: Well..memberAnthony_Yio20:32 9 Mar '03  
GeneralRe: Well..memberpeppeddu20:07 6 Mar '04  
GeneralRe: Well..memberluvskennychesney18:23 28 Oct '04  
GeneralRe: Well..membergeblack7:22 29 Jul '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 12 Jun 2002
Editor: James Spibey
Copyright 2002 by Srinivas Chintakindi
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project