Compare commits
3 Commits
10039eff21
...
fdbe498237
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdbe498237 | ||
|
|
ed42745ff4 | ||
|
|
ea3f91e28d |
@@ -7,7 +7,7 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace lottery_co_uk_scraper.NationalLottery
|
||||
{
|
||||
internal class DrawWinnerInformation
|
||||
internal partial class DrawWinnerInformation
|
||||
{
|
||||
public static void ProcessTableSection(HtmlNode table, string sectionTitle, LottoResult lottoResult)
|
||||
{
|
||||
@@ -419,7 +419,7 @@ namespace lottery_co_uk_scraper.NationalLottery
|
||||
|
||||
var textNodes = htmlDoc.DocumentNode.DescendantsAndSelf().Where(n => n.NodeType == HtmlNodeType.Text);
|
||||
|
||||
var numericValues = textNodes.SelectMany(n => Regex.Matches(n.InnerHtml, @"(\d+)").Cast<Match>())
|
||||
var numericValues = textNodes.SelectMany(n => MyRegex().Matches(n.InnerHtml).Cast<Match>())
|
||||
.Select(match => int.Parse(match.Groups[1].Value))
|
||||
.ToList();
|
||||
|
||||
@@ -449,7 +449,6 @@ namespace lottery_co_uk_scraper.NationalLottery
|
||||
|
||||
string columnTitle = prizePerWinnerNode.Attributes["data-title"].Value;
|
||||
|
||||
// Now you can use regularPrizePerWinner and rolldownPrizePerWinner as needed
|
||||
Console.WriteLine($"Prize per winner ({sectionTitle}): {regularPrizePerWinner}");
|
||||
Console.WriteLine($"Rolldown Prize per winner ({sectionTitle}): {rolldownPrizePerWinner}");
|
||||
|
||||
@@ -531,5 +530,8 @@ namespace lottery_co_uk_scraper.NationalLottery
|
||||
{
|
||||
AssignValueToModelProperty(sectionTitle, columnTitle, LotteryTableRow.Total, winnersNode, lottoResult);
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"(\d+)")]
|
||||
private static partial Regex MyRegex();
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,14 @@ namespace lottery_co_uk_scraper.Utilities
|
||||
{
|
||||
public static async Task<List<string>> ExtractUrlsAsync(string url)
|
||||
{
|
||||
List<string> urls = new List<string>();
|
||||
List<string> urls = [];
|
||||
|
||||
using (HttpClient client = new HttpClient())
|
||||
using (HttpClient client = new())
|
||||
{
|
||||
string content = await client.GetStringAsync(url);
|
||||
MatchCollection matches = MyRegex().Matches(content);
|
||||
|
||||
foreach (Match match in matches)
|
||||
foreach (Match match in matches.Cast<Match>())
|
||||
{
|
||||
string capturedUrl = match.Groups[1].Value;
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace lottery_co_uk_scraper.Utilities
|
||||
}
|
||||
}
|
||||
}
|
||||
urls.Reverse();
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user