Implement Dependency Injection for HttpClient
This commit is contained in:
@@ -7,10 +7,8 @@ namespace lottery_co_uk_scraper
|
||||
{
|
||||
internal class Lotto
|
||||
{
|
||||
public static async Task GetLottoNumbers(string url)
|
||||
public static async Task GetLottoNumbers(string url, HttpClient client)
|
||||
{
|
||||
using HttpClient client = new();
|
||||
|
||||
try
|
||||
{
|
||||
string html = await client.GetStringAsync(url);
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
{
|
||||
static async Task Main()
|
||||
{
|
||||
string url = "https://www.lottery.co.uk/lotto/results-22-07-2023";
|
||||
using HttpClient client = new();
|
||||
string url = "your_lottery_url_here";
|
||||
|
||||
await Lotto.GetLottoNumbers(url);
|
||||
await Lotto.GetLottoNumbers(url, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user