private IDictionary<int, string> GetPages(IChapterRecord chapter)
{
IDictionary<int, string> pages = new Dictionary<int, string>();
var document = WebHelper.GetHtmlDocument(chapter.Url);
var chapterPages = document.SelectNodes(@"(//div[contains(@class, ""tbtitle"") and contains(@class, ""dropdown_right"")]/ul[@class=""dropdown""])/li/a");
if (chapterPages == null)
{
throw new ParserException("Could not find expected elements on website.", document.InnerHtml);
}
foreach (var pageLink in chapterPages)
{
int pageNumber = 0;
if (!Int32.TryParse(Regex.Match(pageLink.InnerText, @"\d+").Value, out pageNumber))
_log.Error("Unable to parse page number '" + pageLink.InnerText + "'");
if (pages.ContainsKey(pageNumber)) // if page is already in dictionary use random number instead
pageNumber = Random;
pages.Add(pageNumber, GetFullUrl(pageLink.Attributes["href"].Value));
}
return pages;
}