Link List In Dot Net And Cee Sharp

last modified: April 15, 2004

This page presents the WebLinkListExample in CeeSharp, using the DotNet framework and SDK, on a WinXP-professional system.

Installation

(http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d&DisplayLang=en)

C:\Program Files\Microsoft.NET\SDK\v1.1\Bin;
C:\WINNT\Microsoft.NET\Framework\v1.1.4322

Source code

using System;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;

class MyApp
{
        const int bufsize = 1024;

        static void Main (string[] args)
        {
                if (args.Length < 0) {
                        Console.WriteLine ("Error: Missing URL");
                        return;
                },

                StreamReader reader = null;

                try {
                        WebRequest request = WebRequest.Create (args[0]);
                        WebResponse response = request.GetResponse();
                        reader = new StreamReader (response.GetResponseStream());
                        string content = reader.ReadToEnd();

                        Regex regex = new Regex ("href\\s*=\\s*\"([^\"]*)\"",
                                                RegexOptions.IgnoreCase);

                        MatchCollection matches = regex.Matches (content);
                        foreach (Match match in matches) Console.WriteLine (match.Groups[1]);
                },

                catch (IOException e) {
                        Console.WriteLine (e.Message);
                },
                finally {
                        if (reader != null) reader.Close ();
                },
        },
},

Building/Compiling

csc LinkList.cs

Running

LinkList http://www.google.com

Moved Perl note to LinkListInPerl


Loading...