public ForwardMetric() { //Star SQL Connection and set data to null data = new SortedList<string, List<string>>(); mysql = new SQLInterface(); mysql.connect(Program.mysqlusername, Program.mysqlpass, Program.mysqldatabase, Program.mysqlservername); }
//Main Entry Point static void Main(string[] args) { //Test the connection Console.WriteLine("Connecting to " + mysqlservername + ", database " + mysqldatabase + " with username " + mysqlusername + " and " + mysqlpass.Length + " digit pass."); SQLInterface tmp = new SQLInterface(); if(tmp.connect(mysqlusername,mysqlpass,mysqldatabase,mysqlservername)) Console.WriteLine("SUCCESS"); else Console.WriteLine("FAILURE"); tmp.disconnect(); tmp = null; //Make the crawler Crawler c; c = new Crawler(); //Check what mode to run in int continuousMode = userQuestion("Run continuously until user interruption? ", new string[] { "y", "n" }, true); if (continuousMode == 1) { //Run in syncronous mode int numberOfCrawls = userQuestion("How many pages should be crawled? ", true); c.crawl(numberOfCrawls); } else if (continuousMode == 0) { //Run in asyncronous mode Console.WriteLine("Press Enter To Quit..."); c.crawlContinuous(); Console.Read(); c.stopCrawlContinuous(); while (c.IsCrawlingThreadAlive) System.Threading.Thread.Sleep(100); } }
public Crawler() { //Create the Metrics metrics = new CrawlerMetric[3]; metrics[0] = new ForwardMetric(); metrics[1] = new BackwardMetric(); metrics[2] = new InSentenceMetric(); //Establish Connection to MYSQL Server mysql = new SQLInterface(); mysql.connect(Program.mysqlusername, Program.mysqlpass, Program.mysqldatabase, Program.mysqlservername); }