parse a web page in ASP using c#

J

Joseph Millman

I'm attempting to write a function that grabs a page from a web server and
reads it into either a string or a HTML or XML object that can be parsed to
retrieve the desired bits of data. My immediate use is in an ASP or ASP.NET
page, but I have a need for the same sort of functionality to automate the
population of a database.



I'm reasonably sure I can write the parsing, but it's the actual retrieving
of the web page that's my present roadblock. I'm sure that there's an object
and suite of functions to do this, I just can't seem to find them...



I would prefer to use c# as it's my language of choice at the moment;
however as my target platforms are all windows there can be a bit of leeway.
 
N

Nicholas Paldino [.NET/C# MVP]

Joseph,

You can use the WebClient class, or, if you need more control over the
download, the HttpWebRequest and HttpWebResponse classes.

If you are going to use an HTML parser, then that parser might already
have the capability to download the content from the web (the MSHTML parser,
for example, can do this).
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Joseph Millman said:
I'm attempting to write a function that grabs a page from a web server and
reads it into either a string or a HTML or XML object that can be parsed
to retrieve the desired bits of data. My immediate use is in an ASP or
ASP.NET page, but I have a need for the same sort of functionality to
automate the population of a database.



I'm reasonably sure I can write the parsing, but it's the actual
retrieving of the web page that's my present roadblock. I'm sure that
there's an object and suite of functions to do this, I just can't seem to
find them...



I would prefer to use c# as it's my language of choice at the moment;
however as my target platforms are all windows there can be a bit of
leeway.

Take a look at HttpWebRequest class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top