static void Main(string[] args) { using (WebScanner scanner = new WebScanner()) { List <Link2> list = new List <Link2>(); scanner.TargetFound += (page, links) => { Console.WriteLine($"\nL: {page.level} Page:\n\t{page.url}\nLinks:"); foreach (var link in links) { Console.WriteLine($"\tL: {link.level} Url: {link.url}\n\tName: {link.name}"); } }; scanner.TargetFound += (page, links) => { list.Add(new Link2(page.url.ToString(), page.name, page.level)); foreach (var link in links) { list.Add(new Link2(link.url.ToString(), link.name, link.level)); } }; Console.WriteLine("Url:"); string Url = Console.ReadLine(); Console.WriteLine("Count of pages to analize:"); int count = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Limit of pages to show"); int limit = Convert.ToInt32(Console.ReadLine()); scanner.Scan(new Uri(Url), count, limit, 0); using (var stream = new StreamWriter(fileName)) using (var csvReader = new CsvWriter(stream, System.Globalization.CultureInfo.InvariantCulture)) { csvReader.Configuration.Delimiter = ";"; csvReader.WriteRecords(list); stream.Flush(); } } }
public async Task TestThatScannerDownloadsJson() { WebScanner scanner = new WebScanner(@"https://www.meneame.net/backend/sneaker2"); Assert.IsTrue(IsValidJson(await scanner.DownloadData())); }