Here is a console application to have web feed directly into your application.By default, the .NET Framework supports URIs that begin with http:, https:, ftp:, and file: scheme identifiers.
===========================
Program.cs
===========================
using System;
using System.IO;
using System.Net;
namespace Extract_Direct_WebData
{
class Program
{
void Execute()
{
try
{
WebClient client = new WebClient();
//If you need to add headers
//client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Stream data = client.OpenRead("http://www.google.com");
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
Console.WriteLine(s);
Console.ReadLine();
data.Close();
reader.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + ex.StackTrace.ToString());
Console.ReadLine();
}
}
static void Main(string[] args)
{
Program p=new Program();
p.Execute();
}
}
}
=========================
Result
=========================
Thursday, June 19, 2008
Direct Streaming in .NET
Posted by Rajnish Bhatia at 5:39 PM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment