473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Reading the contents of a page through its URL

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 19 '06 #1
2 1182
Hi,

What is wrong with that code?

you could use a memorystream to store all the page in memory and then later
send it back in the response.
--
Ignacio Machin
machin AT laceupsolutions.com
"Kuldeep" <ku****************@hotmail.comwrote in message
news:u4**************@TK2MSFTNGP02.phx.gbl...
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 19 '06 #2
Hi Machin,

Nothing is wrong with the piece of code that I showed.
All I am looking forward for is an alternative method to achieve the same.
Something which could be as dynamic as a "Ctrl + F" search on a HTML page.
With which I can avoid the overkill of reading the entire data through a
Stream Reader.

Any leads on this would be very helpful

Thanks,
Kuldeep
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:en**************@TK2MSFTNGP05.phx.gbl...
Hi,

What is wrong with that code?

you could use a memorystream to store all the page in memory and then
later send it back in the response.
--
Ignacio Machin
machin AT laceupsolutions.com
"Kuldeep" <ku****************@hotmail.comwrote in message
news:u4**************@TK2MSFTNGP02.phx.gbl...
>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 19 '06 #3

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

Similar topics

0
by: Steve_EE | last post by:
I'm running phpMyAdmin 2.5.3 / MySQL 4.0.14 / PHP 4.3.3 / Apache 1.3.20 phpMyAdmin is installed and appears ok at first, I can login, select databases, view which tables are in each db, see the...
1
by: Jeff Thies | last post by:
I'm (still) having trouble reading the contents of an IFRAME (IE5). I have this: var my_iframe = document.frames; What I would want to do at that point is get either the...
6
by: Foxy Kav | last post by:
Hi, another question from me again, i was just wondering if anyone could give me a quick example of reading data from a file then placing the data into an array for some manipulation then reading...
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
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...
1
by: paulnightingale | last post by:
Hi I've got a ticker tape that is written in Java Script 1.2 which displays text that has to be currently changed in the program code. What I want to do is to find the bit of javascript to get the...
1
by: David | last post by:
Hi, This one appears a little strange to me. Here is the scenario. I load a datalist the first time a page is run. The page has a !IsPostback and the datalist gets loaded at this point. I...
1
by: 4levels | last post by:
Dear Folks, I stumbled upon a strange behaviour of the XMLHttpRequest.. Maybe I'm just not well informed enough about its possibilities, so could someone please confirm my question? When I...
1
by: Adrian | last post by:
Hi I need to write an application that can read the contents of IE6. Basically the user opens an intranet site and displays a page then from within an app they click a button that first checks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.