Solved

Extract web page html code by given web page address

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.php tree directory? 5 57
C# HTTP GET method sample code 3 41
C# guarantee sql connection close 6 32
execute script based on HTML event 7 0
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

867 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

18 Experts available now in Live!

Get 1:1 Help Now