Solved

Extract web page html code by given web page address

Posted on 2011-03-18
2
306 Views
Last Modified: 2012-08-13
Hi, suppose a web page link is given. Can I get the page source code?
For example:
 http://www.experts-exchange.com/

Open in new window

is given than the html code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
  // <![CDATA[
  var eeTimerStart = new Date().getTime();
  var eeTimerCnt = 0;
  var eeAdsLoaded = 0;
  var ourMs = 0;
  var adMs = 0;
  
  function eeEncode(str)
  {
     str = escape(str);
     str = str.replace('+', '%2B');
     str = str.replace('%20', '+');
     str = str.replace('*', '%2A');
     str = str.replace('/', '%2F');
     str = str.replace('@', '%40');
     return str;
  }
  
  function endEETimer()
  {
      if (++eeTimerCnt == 4) {
         ourMs = (new Date().getTime() - eeTimerStart);
         eeTimerStart = new Date().getTime();
      
      } 
      if (eeTimerCnt == 5 && eeAdsLoaded == 1) {
         adMs = (new Date().getTime() - eeTimerStart);
         eeTimerStart = new Date().getTime();
      }
      if (eeTimerCnt == 6) {
         var omnitureMs = (new Date().getTime() - eeTimerStart);
         var img = document.createElement("img");
         img.src="/pageLoaded.jsp?url=" + eeEncode(document.location.href) + 
                 "&isNew=0" +
                 "&adMs=" + adMs + "&ourMs=" + ourMs + "&omnitureMs=" + omnitureMs + 
                 "&isSecure=0" + 
                 "&isExpertSkin=0" + 
                 "&isVS=0" + 
                 "&isUsingCDN=0" +
                 "&isUsingEELevel3CDN=1" +
                 "&isUsingEEDigitalWestCDN=0" +
                 "&isConsolidatedCSS=1"; 
         

         document.body.appendChild(img)
 

      }
  }
 
  // ]]>
  </script>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" href="/images/ee.ico" type="image/x-icon" />

<style type="text/css">@import "http://images.experts-exchange.com/getCSS?key=/00206/ee_NS|--base,xp--base,--component,xp--component,--formFactory,xp--formFactory,xp--button,xp-include-infoBox&t=1299910051000";</style>
<style type="text/css">@import "http://images.experts-exchange.com/getCSS?key=/00206/ee_NS|-jsp-indexLoggedIn,xp-jsp-indexLoggedIn,-include-questionList,xp-include-questionList,xp-include-searchForAnswers,xp-include-welcomeGuide,xp-include-corpAd,xp-include-rootTAHeader,xp-include-updateMessage,-include-questionSubmitted,xp-include-questionSubmitted,-include-codeSnippet,xp-include-codeSnippet,-include-question,xp-include-question,-include-customEEple,xp-include-customEEple,xp-include-ranks,xp-include-qualifiedExpertMessage,xp-include-outsideBookmarks,xp-include-welcomeQuestion,xp-include-questionScore,xp-include-findYourSolution,xp-include-recentActivityFeed,xp-include-actionBox,-include-corpAdBannerLI,xp-include-corpAdBannerLI,-include-expertZoneOverlay,xp-include-expertZoneOverlay,-include-welcomeBottomOverlay,xp-include-welcomeBottomOverlay&t=1299910051000";</style>
<script src="http://images.experts-exchange.com/00206/scripts/eeSubs_8fd303295f70c1423099a23823d4f8ba.js" type="text/javascript"></script>
<meta name="alexaVerifyID" content="EEyq-1NAv4sP8nJvMcuCYJ4YqjU" />
  <meta name="msvalidate.01" content="19C984E796A6C2E12B5745B0A771521A" />
<title>Experts Exchange</title>
<link rel="alternate" type="application/atom+xml" title="Experts Exchange Articles" href="/articleFeed.jsp" />
<link rel="alternate" type="application/atom+xml" title="Experts Exchange Questions" href="/questionFeed.jsp" />
<script src="http://images.experts-exchange.com/00206/scripts/s_code_0a522bfb0687449fe5b609a65bced569.js" type="text/javascript"></script> </head>
<body style="height: 100%;" class="IE8" >

 <div id="minWidth"></div>
<div class="outerBodyWrap indexLoggedInJSP">
  <div class="bodyWrap">
  <div id="outerWrap">
   <div id="innerWrap" class="innerWrap" style="">
   <div id="pageHeader"
      >
        <!-- top options -->
        <ul class="navTopOptions">
<!--   many many lines available

Open in new window

0
Comment
Question by:zhshqzyc
2 Comments
 
LVL 2

Assisted Solution

by:tonykachappilly
tonykachappilly earned 150 total points
ID: 35167779
http://www.codeproject.com/KB/aspnet/ZetaWebSpider.aspx
check this link u'll get a solution
0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 350 total points
ID: 35167810
You can use something like this:

var client = new System.Net.WebClient ();
string content = string.Empty;

client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

using (Stream data = client.OpenRead ("http://www.experts-exchange.com/"))
{
	using (StreamReader reader = new StreamReader (data))
	{
		content = reader.ReadToEnd ();
		Console.WriteLine (content);
	}
}

Open in new window

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now