-
Notifications
You must be signed in to change notification settings - Fork 4
/
Program.cs
37 lines (33 loc) · 1.25 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using HtmlAgilityPack;
using prospect_scraper_mddb_2022.Extensions;
using SharpConfig;
using Spectre.Console;
namespace prospect_scraper_mddb_2022
{
public class Program
{
public static void Main(string[] args)
{
var scraperConfig = Configuration.LoadFromFile("scraper.conf");
var pageSection = scraperConfig["Pages"];
var generalSection = scraperConfig["General"];
AnsiConsole
.Status()
.Start("Thinking...", ctx =>
{
ctx.Spinner(Spinner.Known.Star);
var webGet = new HtmlWeb
{
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"
};
string[] scrapeYears = generalSection["YearsToScrape"].StringValueArray;
foreach (string scrapeYear in scrapeYears)
{
string urlToScrape = pageSection.GetUrlToScrape(scrapeYear);
ctx.ScrapeYear(webGet, scrapeYear, urlToScrape);
}
ctx.Status("Done!");
});
}
}
}