This page presents the WebLinkListExample in CeeSharp, using the DotNet framework and SDK, on a WinXP-professional system.
Installation
-
Download the following:
-
Version 1.1 Redistributable framework (http://www.microsoft.com/downloads/details.aspx?familyid=262d25e3-f589-4842-8157-034d1e7cf3a3&displaylang=en)
-
Version 1.1 .Net Framework SDK
-
-
Install the two downloads:
- Run dotnetfx.exe (the redistributable)
- Run setup.exe (the SDK)
-
Append the framework and SDK to the "Path" environment variable (I use the system properties dialog of "My Computer")
C:\Program Files\Microsoft.NET\SDK\v1.1\Bin;
C:\WINNT\Microsoft.NET\Framework\v1.1.4322
Source code
- Create "LinkList.cs" using the editor of your choice.
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
- At a command prompt, in the directory containing the source, type the following:
csc LinkList.cs
Running
- At a command prompt, type the following:
LinkList http://www.google.com
Moved Perl note to LinkListInPerl