Skip to content

Commit

Permalink
구절 받아올 수 있도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
sunghwan2789 committed Jun 18, 2019
1 parent baf5cd6 commit 6e85a9d
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions Bible2PPT/Bibles/Sources/GoodtvBible.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,32 @@ protected override List<BibleBook> GetBooksOnline(BibleVersion bible)
}).ToList();
}

protected override List<BibleChapter> GetChaptersOnline(BibleBook book) => throw new NotImplementedException();
protected override List<BibleVerse> GetVersesOnline(BibleChapter chapter) => throw new NotImplementedException();
protected override List<BibleChapter> GetChaptersOnline(BibleBook book) =>
Enumerable.Range(1, book.ChapterCount)
.Select(i => new BibleChapter
{
Number = i,
}).ToList();
private static string StripHtmlTags(string s) => Regex.Replace(s, @"<.+?>", "", RegexOptions.Singleline);

protected override List<BibleVerse> GetVersesOnline(BibleChapter chapter)
{
var data = Encoding.UTF8.GetString(client.UploadValues("/bible.asp", new System.Collections.Specialized.NameValueCollection
{
{ "bible_idx", chapter.Book.OnlineId },
{ "jang_idx", chapter.Number.ToString() },
{ "bible_version_1", chapter.Book.Bible.OnlineId },
{ "bible_version_2", "0" },
{ "bible_version_3", "0" },
{ "count", "1" },
}));
data = Regex.Match(data, @"<p id=""one_jang""><b>([\s\S]+?)</b></p>").Groups[1].Value;
var matches = Regex.Matches(data, @"<b>(\d+).*?</b>(.*?)<br>");
return matches.Cast<Match>().Select(i => new BibleVerse
{
Number = int.Parse(i.Groups[1].Value),
Text = StripHtmlTags(i.Groups[2].Value),
}).ToList();
}
}
}

0 comments on commit 6e85a9d

Please sign in to comment.