def _get_online_chapter(self, book_name, book_chapter,<EOL>cache_chapter):
url = self.build_recovery_online_url(book_name, book_chapter)<EOL>logging.debug("<STR_LIT>".format(url))<EOL>r = requests.get(url)<EOL>if r.status_code != <NUM_LIT:200>:<EOL><INDENT>logging.error("<STR_LIT>".format(<EOL>book_name,<EOL>book_chapter,<EOL>url))<EOL>raise Exception("<STR_LIT>".format(<EOL>book_name,<EOL>book_chapter,<EOL>url))<EOL><DEDENT>chapter_html = r.text<EOL>soup = BeautifulSoup(chapter_html, '<STR_LIT>')<EOL>verses_list_soup = soup.get_text().split('<STR_LIT:\n>')<EOL>verses_list = []<EOL>verse_num = <NUM_LIT:1><EOL>for verse in verses_list_soup:<EOL><INDENT>verse = self._remove_non_ascii(verse)<EOL>if re.search(r'<STR_LIT>', verse):<EOL><INDENT>verses_list.append(<EOL>re.sub(r'<STR_LIT>',<EOL>str(verse_num) + "<STR_LIT:.>",<EOL>verse))<EOL>verse_num += <NUM_LIT:1><EOL><DEDENT><DEDENT>logging.debug("<STR_LIT>".format(<EOL>book_name,<EOL>book_chapter))<EOL>if cache_chapter:<EOL><INDENT>base_dir = os.path.expanduser("<STR_LIT>")<EOL>book_dir = "<STR_LIT>".format(base_dir, book_name)<EOL>chapter_file = "<STR_LIT>".format(book_dir, book_chapter)<EOL>if not os.path.isdir(base_dir):<EOL><INDENT>os.mkdir(base_dir)<EOL><DEDENT>if not os.path.isdir(book_dir):<EOL><INDENT>os.mkdir(book_dir)<EOL><DEDENT>if not os.path.isfile(chapter_file):<EOL><INDENT>f = open(chapter_file, '<STR_LIT:w>')<EOL>f.write("<STR_LIT:\n>".join(verses_list))<EOL>f.close()<EOL><DEDENT><DEDENT>return verses_list<EOL>
Retrieves an entire chapter of a book in the Bible in the form of a
list.
If cache_chapter is "True", this method will cache the chapter
in "~/.diyr/bible/<book>/<chapter>.txt".