Solved

Extract web page html code by given web page address

Posted on 2011-03-18
2
315 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

685 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