PC Review


Reply
Thread Tools Rate Thread

HOw to get sourc from url

 
 
=?Utf-8?B?SWNlQ29sZEZpcmU=?=
Guest
Posts: n/a
 
      11th Dec 2004
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
 
Reply With Quote
 
 
 
 
Morten Wennevik
Guest
Posts: n/a
 
      11th Dec 2004
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++.

--
Happy Coding!
Morten Wennevik [C# MVP]
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SWNlQ29sZEZpcmU=?=
Guest
Posts: n/a
 
      13th Dec 2004
Thanks Morten...
It worked..

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

Bye
ICF C#

"Morten Wennevik" wrote:

> 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++.
>
> --
> Happy Coding!
> Morten Wennevik [C# MVP]
>

 
Reply With Quote
 
Morten Wennevik
Guest
Posts: n/a
 
      13th Dec 2004
On Sun, 12 Dec 2004 21:23:02 -0800, IceColdFire
<(E-Mail Removed)> wrote:

> 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/Interne...serInCSMDB.asp
http://www.codeproject.com/csharp/webbrowser.asp

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

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

--
Happy Coding!
Morten Wennevik [C# MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best solution to share linked excel data without endangering sourc =?Utf-8?B?TWF0dDcxMDI=?= Microsoft Excel Misc 2 7th Dec 2005 10:16 PM
Re: Deserializing double.NaN generates exception in framwork sourc Nicholas Paldino [.NET/C# MVP] Microsoft C# .NET 1 30th Aug 2005 08:15 PM
Dropdown list from another spreadsheet doesn't work if close sourc =?Utf-8?B?S3VjaGU=?= Microsoft Excel Misc 1 30th Jun 2005 01:03 AM
How to chage Absolute url to relative url ,and relative url to absolute url gqtang Microsoft C# .NET 1 13th Sep 2003 05:22 AM
same sourc? sobig Stephen Falken III Anti-Virus 1 3rd Sep 2003 07:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 PM.