Fix BG refactor

This commit is contained in:
Jon Tibble 2010-07-24 02:10:57 +01:00
parent c8c65120cf
commit ccda22a962

View File

@ -198,20 +198,20 @@ class BGExtract(BibleCommon):
urlstring = u'http://www.biblegateway.com/passage/?search=%s+%s' \ urlstring = u'http://www.biblegateway.com/passage/?search=%s+%s' \
u'&version=%s' % (bookname, chapter, version) u'&version=%s' % (bookname, chapter, version)
log.debug(u'BibleGateway url = %s' % urlstring) log.debug(u'BibleGateway url = %s' % urlstring)
# Let's get the page, and then open it in BeautifulSoup, so as to
# attempt to make "easy" work of bad HTML.
page = urllib2.urlopen(urlstring) page = urllib2.urlopen(urlstring)
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
soup = BeautifulSoup(page) soup = BeautifulSoup(page)
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
text = str(soup.find(u'div', u'result-text-style-normal')) content = soup.find(u'div', u'result-text-style-normal')
useful_soup = BeautifulSoup(text) verse_count = len(soup.findAll(u'sup', u'versenum'))
verses = useful_soup.findAll(u'p') found_count = 0
verse_list = {} verse_list = {}
for verse in verses: while found_count < verse_count:
if verse.sup: content = content.findNext(u'sup', u'versenum')
verse_list[int(str(verse.sup.contents[0]))] = \ raw_verse_num = content.next
unicode(verse.contents[-1]) raw_verse_text = raw_verse_num.next
verse_list[int(str(raw_verse_num))] = unicode(raw_verse_text)
found_count += 1
return SearchResults(bookname, chapter, verse_list) return SearchResults(bookname, chapter, verse_list)
class CWExtract(BibleCommon): class CWExtract(BibleCommon):