Beispiel #1
0
        public void TestRandomIdCardNumberSequence()
        {
            var sequence = new RandomIdCardNumberSequence();

            for (int i = 0; i < 100; ++i)
            {
                Console.WriteLine(sequence.Current);
            }
        }
Beispiel #2
0
        public void TestCrawlerWithIdCardNumberSequence()
        {
            var sequence = new RandomIdCardNumberSequence();
            var crawler  = new Crawler(sequence);

            crawler.AfterCrawl += (sender, e) =>
            {
                var progress = e.Progress;
                Console.WriteLine(
                    "[{0}/{1} keyword={2}] {3}",
                    progress.Current, progress.Total, progress.CurrentKeyword, progress.Message);
            };
            crawler.Crawl(100, QueryType.IdCardNumber);
        }
Beispiel #3
0
 private static CrawlContext GetCrawlContext(string sequenceType, string start, long max, int pause)
 {
     ISequence<string> sequence;
     QueryType queryType;
     if (sequenceType.Equals("NN"))
     {
         var innerSequence = new NaturalNumberSequence();
         innerSequence.Seek(long.Parse(start));
         sequence = new TextSequence<long>(innerSequence);
         queryType = QueryType.IdCardNumber;
     }
     else if (sequenceType.Equals("N"))
     {
         sequence = new NameSequence();
         sequence.Seek(start);
         queryType = QueryType.Name;
     }
     else if (sequenceType.Equals("RICN"))
     {
         sequence = new RandomIdCardNumberSequence();
         queryType = QueryType.IdCardNumber;
     }
     else if (sequenceType.Equals("RN1"))
     {
         sequence = new RandomNameSequence(1);
         queryType = QueryType.Name;
     }
     else if (sequenceType.Equals("RN2"))
     {
         sequence = new RandomNameSequence(2);
         queryType = QueryType.Name;
     }
     else
     {
         throw new ArgumentException("Invalid sequence type: " + sequenceType);
     }
     sequence.Initialize();
     return new CrawlContext
     {
         Sequence = sequence,
         SequenceType = sequenceType,
         MaximumTry = max,
         QueryType = queryType,
         Pause = pause,
     };
 }