Program.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:7k
源码类别:

搜索引擎

开发平台:

C#

  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Net;
  6. using System.Net.Sockets;
  7. using System.Threading;
  8. /*
  9.       '       迅龙中文分类搜索引擎  v0.6
  10.       '
  11.       '        LGPL  许可发行
  12.       '
  13.       '       宁夏大学  张冬 康彩  zd4004@163.com
  14.       ' 
  15.       '        官网 http://blog.163.com/zd4004/
  16.  */
  17. namespace XunLong.ConsoleSpiderOne
  18. {
  19.     /// <summary>
  20.     /// 单机本地蜘蛛 
  21.     /// </summary>
  22.     class Program
  23.     {
  24.         static void Main(string[] args)
  25.         {
  26.             Console.WriteLine("  >------------------------------------------<");
  27.             Console.WriteLine("  >------------------------------------------<");
  28.             Console.WriteLine("  >          列表中文搜索引擎_组件v0.3       <");
  29.             Console.WriteLine("  >                   蜘蛛                   <");
  30.             Console.WriteLine("  >------------------------------------------<");
  31.             Console.WriteLine("  >------------------------------------------<");
  32.             string k_c_path = args[0];
  33.             Console.WriteLine("--》加载配置文件: " + k_c_path);
  34.             XunLong.CongifData.Config.InitConfigData(k_c_path);
  35.             //URL 路径 
  36.             string pathi = "";
  37.             //索引的路径  
  38.             string indexPath = "";
  39.            
  40.             string StartTime = DateTime.Now.ToString();
  41.             Console.WriteLine(" ");
  42.             Console.WriteLine("迅龙中文分类搜索引擎 蜘蛛  2006.8");
  43.             Console.WriteLine("启动时间 " + StartTime);
  44.             ClassSpiderMain n = new ClassSpiderMain();
  45.             //开始蜘蛛
  46.             n.StartMain( k_c_path);
  47.          //   n.initNEEDURL(XunLong.CongifData.Config.modelSource);
  48.             n.IsRun = true;
  49.             System.Threading.Thread.Sleep(2000);
  50.            
  51.             Console.WriteLine("输入 X 退出。。。");
  52.             Console.WriteLine("");
  53.             // 开启一个线程 运行
  54.             Thread T1 = new Thread(new ThreadStart(n.ZhiZhuRun));
  55.             T1.Start();
  56.             System.Threading.Thread.Sleep(1000);
  57.             Thread T2 = new Thread(new ThreadStart(n.ZhiZhuRun));
  58.             T2.Start();
  59.             System.Threading.Thread.Sleep(1000);
  60.            Thread T3 = new Thread(new ThreadStart(n.ZhiZhuRun));
  61.            T3.Start();
  62.            System.Threading.Thread.Sleep(1000);
  63.             Thread T4 = new Thread(new ThreadStart(n.ZhiZhuRun));
  64.             T4.Start();
  65.             System.Threading.Thread.Sleep(1000);
  66.             Thread T5 = new Thread(new ThreadStart(n.ZhiZhuRun));
  67.             T5.Start();
  68.             System.Threading.Thread.Sleep(1000);
  69.             Thread T6 = new Thread(new ThreadStart(n.ZhiZhuRun));
  70.             T6.Start();
  71.             System.Threading.Thread.Sleep(1000);
  72.             
  73.             // 开启一个线程 运行
  74.             Thread T7 = new Thread(new ThreadStart(n.ZhiZhuRun));
  75.             T7.Start();
  76.             System.Threading.Thread.Sleep(1000);
  77.             Thread T8 = new Thread(new ThreadStart(n.ZhiZhuRun));
  78.          //   T8.Start();
  79.          //   System.Threading.Thread.Sleep(1000);
  80.             Thread T9 = new Thread(new ThreadStart(n.ZhiZhuRun));
  81.           //  T9.Start();
  82.          //   System.Threading.Thread.Sleep(1000);
  83.             Thread T10 = new Thread(new ThreadStart(n.ZhiZhuRun));
  84.          //   T10.Start();
  85.          //   System.Threading.Thread.Sleep(1000);
  86.           //  Thread T11 = new Thread(new ThreadStart(n.ZhiZhuRun));
  87.           //  T11.Start();
  88.           //  System.Threading.Thread.Sleep(1000);
  89.           //  Thread T12 = new Thread(new ThreadStart(n.ZhiZhuRun));
  90.           //  T12.Start();
  91.          //   System.Threading.Thread.Sleep(1000);
  92.           //  Thread T13 = new Thread(new ThreadStart(n.ZhiZhuRun));
  93.           //  T13.Start();
  94.           //  System.Threading.Thread.Sleep(1000);
  95.            // Thread T14 = new Thread(new ThreadStart(n.ZhiZhuRun));
  96.           //  T14.Start();
  97.           //  System.Threading.Thread.Sleep(1000);
  98.           //  Thread T15 = new Thread(new ThreadStart(n.ZhiZhuRun));
  99.          //   T15.Start();
  100.          //   System.Threading.Thread.Sleep(1000);
  101.          //   Thread T16 = new Thread(new ThreadStart(n.ZhiZhuRun));
  102.            // T16.Start();
  103.           //  System.Threading.Thread.Sleep(1000);
  104.           //  Thread T17 = new Thread(new ThreadStart(n.ZhiZhuRun));
  105.           //  T17.Start();
  106.           //  System.Threading.Thread.Sleep(1000);
  107.            // Thread T18 = new Thread(new ThreadStart(n.ZhiZhuRun));
  108.           //  T18.Start();
  109.          ////   System.Threading.Thread.Sleep(1000);
  110.          //   Thread T19 = new Thread(new ThreadStart(n.ZhiZhuRun));
  111.           //  T19.Start();
  112.          //   System.Threading.Thread.Sleep(1000);
  113.           //  Thread T20 = new Thread(new ThreadStart(n.ZhiZhuRun));
  114.          //   T20.Start();
  115.           //  System.Threading.Thread.Sleep(1000);
  116.            // Thread T21 = new Thread(new ThreadStart(n.ZhiZhuRun));
  117.            // T21.Start();
  118.            // System.Threading.Thread.Sleep(1000);
  119.            //// Thread T22 = new Thread(new ThreadStart(n.ZhiZhuRun));
  120.           //  T22.Start();
  121.           //  System.Threading.Thread.Sleep(1000);
  122.             //等待一个输入
  123.             while (true)
  124.             {
  125.            
  126.                 Console.ReadKey();
  127.                 Console.WriteLine("停止蜘蛛");
  128.                // Console.ReadKey();
  129.                // if ((a == "x") |  (a == "X"))
  130.                 //{
  131.                 n.IsRun = false;
  132.                     T1.Abort();
  133.                     
  134.                     T2.Abort();
  135.                     T3.Abort();
  136.                     T4.Abort();
  137.                     T5.Abort();
  138.                     T6.Abort();
  139.                     T7.Abort();
  140.                     T8.Abort();
  141.                     T9.Abort();
  142.                     T10.Abort();
  143.                  //   T11.Abort();
  144.                   //  T12.Abort();
  145.                   //  T13.Abort();  
  146.                 //    T14.Abort();  
  147.                 //    T15.Abort();
  148.                 //    T16.Abort();
  149.                 //    T17.Abort();
  150.                //     T18.Abort();
  151.                   //  T19.Abort();
  152.                  //   T20.Abort();
  153.                  //   T21.Abort();
  154.                  //   T22.Abort();
  155.                     Console.WriteLine("");
  156.                     Console.WriteLine("停止蜘蛛");
  157.                     //蜘蛛停止
  158.                     n.StopSpider();
  159.                     string EndTime = DateTime.Now.ToString();
  160.                     Console.WriteLine("");
  161.                     Console.WriteLine("启动时间 " + StartTime + "  结束时间   " + EndTime + "  此次总共下载   " + n.Num.ToString());
  162.                     Console.WriteLine("");
  163.                     Console.WriteLine("任意键关闭。。。");
  164.                     //显示统计信息
  165.                      Console.ReadKey();
  166.                     return;
  167.                // }
  168.                 
  169.             }
  170.         }
  171.     }
  172. }