Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintHelp();
                Console.Read();
                return;
            }

            log4net.Config.XmlConfigurator.Configure();

            string targetUrl = args[0], outputDirectory = string.Empty;

            if (args.Length > 1)
            {
                outputDirectory = args[1];
            }

            var dirName = CreateOutputDir(outputDirectory, targetUrl);

            var queue = new SimpleQueue();
            var scraper = new ImageScraper(queue, targetUrl, dirName);
            var downloader = new ImageDownloader(queue, dirName);

            var scraperThread = new Thread(scraper.ScrapeAll);
            var downloaderThread = new Thread(downloader.Download);

            downloaderThread.Start();
            scraperThread.Start();

            Process.Start(dirName);

            downloaderThread.Join();
            scraperThread.Join();
        }
 public ImageDownloader(SimpleQueue queue, string dirName)
 {
     this.queue = queue;
     this.dirName = dirName;
 }
 public ImageScraper(SimpleQueue queue, string targetUrl, string dirName)
 {
     this.queue = queue;
     this.targetUrl = targetUrl;
     this.dirName = dirName;
 }