tags:

views:

35

answers:

0

Hi guys,

I'm trying to buffen up my C# knowledge and experience so I am converting a Python script I wrote to C#. The script converts and stores the user's browser cookies into a text file. It then uses them to log into a website that uses WLID stores the new live.com cookies and the websites own user cookies; then scrapping the source of the HTML page.

I've done some research and c#.net seems to have a lot of different ways to achieve a cookie login. What's the best way to achieve this in the simplest form?

My request:

using System;
using System.Net;
using System.IO;

public class Test
{
    public static void Main()
    {
        WebClient client = new WebClient();
        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);
        data.Close();
        reader.Close();
    }
}