HOw to get sourc from url

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I need to write C# component to extract html source from any url(iternte or
intranet)

Also I have been a pro C++ programmer. How dep can I go in C#. Is it equal,
less or more powerfull than C++ in terms of technicality and awareness of the
underlying layers

Kindly guide

Thanks
C# Pro
 
Hi IceColdFire,

..Net has classes for communicating through http,
HttpWebRequest/HttpWebResponse.
To download the html source from a given url simply create a
HttpWebRequest object, and use its HttpWebResponse to get the stream for
the page.

HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("http://www.utbnord.se");
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string source = sr.ReadToEnd();

You might want to use the HttpWebResponse.ContentEncoding property, if
available, when creating the StreamReader.

As for how deep, I guess you could do it using the Tcp and Socket classes,
but I never tried it, nor am I familiar with how to do it in C++.
 
Thanks Morten...
It worked..

Also from where can I get IE Plugin coding details using C#..

Bye
ICF C#
 
Thanks Morten...
It worked..

Also from where can I get IE Plugin coding details using C#..

I'm not sure I follow you. There is a Microsoft Web Browser COM object
you can use to display web pages in %windir%\system32\shdocvw.dll.

An couple of examples using this control:
http://www.c-sharpcorner.com/Internet/WebBrowserInCSMDB.asp
http://www.codeproject.com/csharp/webbrowser.asp

However, this thread looks like it might be more relevant
http://www.dotnet247.com/247reference/msgs/51/255003.aspx

Also, you might want to reask this question in a new thread.
 
Back
Top