Click here to Skip to main content
6,304,948 members and growing! (18,984 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
Win2K, WinXP, ASP, Dev
Posted:12 Jun 2002
Views:107,057
Bookmarked:37 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
23 votes for this article.
Popularity: 4.99 Rating: 3.67 out of 5
4 votes, 22.2%
1

2
1 vote, 5.6%
3
4 votes, 22.2%
4
9 votes, 50.0%
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


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

Other popular ASP articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 19 of 19 (Total in Forum: 19) (Refresh)FirstPrevNext
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  
Generalhow can i read UTF-8 Characters? PinsussTogrim23:08 1 Jul '03  
GeneralRe: 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    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
Web11 | Advertise on the Code Project