Skip to content

Instantly share code, notes, and snippets.

@vmandic
Created October 19, 2018 19:32
Show Gist options
  • Save vmandic/14f9215ca0c9c91490c19752bbf0c150 to your computer and use it in GitHub Desktop.
Save vmandic/14f9215ca0c9c91490c19752bbf0c150 to your computer and use it in GitHub Desktop.
meds-processor, p2, s8
ISet<HzzoMedsDownloadDto> ParseMedsLiElements(IEnumerable<IElement> elems) =>
elems.Aggregate(new HashSet<HzzoMedsDownloadDto>(), (medsList, li) =>
{
var href = li.QuerySelector("a").GetAttribute("href");
// NOTE: this domain is not available, links don't work :-(
if (!href.Contains("cdn.hzzo.hr"))
{
var dtParts = li.TextContent.TrimEnd().Split(' ').LastOrDefault().Split('.');
var downloadDto = new HzzoMedsDownloadDto(
href,
$"{dtParts[2]}-{dtParts[1]}-{dtParts[0]}",
Path.Combine(_appPathsInfo.ApplicationRootPath, DOWNLOAD_DIR)
);
// NOTE: that's it folks, docs from 2013 and older are messed up
// and can't be approached with this generic parser in this app
// A more sophisticated parser (more if/else loops...) would be needed
if (downloadDto.ValidFrom > filterDtParsable2013)
medsList.Add(downloadDto);
}
return medsList;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment