473,466 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Read contents of a web page

Hi All,

I am trying to read the contents of a page through its URL.

My code snippet is as follows:
public void mtdGetPageDataHWR()
{
HttpWebRequest objRequ =
(HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
HttpWebResponse objResp = (HttpWebResponse)objRequ.GetResponse();
string strVersion = objResp.ProtocolVersion.ToString();
StreamReader objRd = new StreamReader(objResp.GetResponseStream());
string strRd = objRd.ReadLine();
while(strRd!=null)
{
Response.Write(strRd);
strRd = objRd.ReadLine();
}
}

Is there any other way to achieve this which could be more efficient or
faster than this.

Any help on this would be very handy

Thanks,

Kuldeep
Oct 24 '06 #1
1 980
Yes, check out my blog post about loading and parsing HTML using the
Html Agility Pack:
http://chrisfulstow.blogspot.com/200...ml-in-net.html

--
Chris Fulstow
MCP, MCTS
http://chrisfulstow.blogspot.com/

Kuldeep wrote:
Hi All,

I am trying to read the contents of a page through its URL.

My code snippet is as follows:
public void mtdGetPageDataHWR()
{
HttpWebRequest objRequ =
(HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
HttpWebResponse objResp = (HttpWebResponse)objRequ.GetResponse();
string strVersion = objResp.ProtocolVersion.ToString();
StreamReader objRd = new StreamReader(objResp.GetResponseStream());
string strRd = objRd.ReadLine();
while(strRd!=null)
{
Response.Write(strRd);
strRd = objRd.ReadLine();
}
}

Is there any other way to achieve this which could be more efficient or
faster than this.

Any help on this would be very handy

Thanks,

Kuldeep
Oct 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marcel Brekelmans | last post by:
Hi, This is my situation: My ISP doesn't allow me the execute server-code. So, no ASP or otherwise.As a small compensation, they run some CGI scripts that we can use. With one of these...
4
by: ESPN Lover | last post by:
Below is two snippets of code from MSDN showing how to read a file. Is one way preferred over the other and why? Thanks. using System; using System.IO; class Test { public static void...
1
by: Beowulf | last post by:
I have a report laid out in Design View as shown at the end of this message. I have code that performs the following steps: 1. In main report's Report_Open(), DELETE any old rows in tblTOC for...
3
by: dave_nul | last post by:
Hello. I'm trying to read the contents of any Web page on another host. I'm finding that... echo file_get_contents( 'http://www.php.net' ); .... works fine if I upload the PHP script to my...
3
by: Jim S | last post by:
I have a need to read the contents of an html table on a remote web page into a variable. I guess this is called screen scraping but not sure. I'm not sure where to start or what the best...
4
by: Kuldeep | last post by:
Hi All, I am trying to read the contents of a page through its URL. My code snippet is as follows: public void mtdGetPageDataHWR() { HttpWebRequest objRequ =...
9
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to...
0
by: jayasabari | last post by:
Hai, I am reading the content form the msword file and displaying(writing) in aspx page(i.e., .net page). The content is displaying but some symbole is displaying My codding: ...
2
by: dakshayini | last post by:
hi all, I will browse the file and read the name of file in my web page.similarly i need to read the contents of that browsed file into my web page.Is it possible to read and write the contents of...
28
by: tlpell | last post by:
Hey, read some tips/pointers on PHP.net but can't seem to solve this problem. I have a php page that reads the contents of a file and then displays the last XX lines of the file. Problem is...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.