From 4b5ad13eec20d417b3512b9817a302189ff08c80 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 24 Jul 2010 13:59:02 +0100 Subject: [PATCH 1/2] Fix numbered book BG bibles --- openlp/plugins/bibles/lib/http.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 8bf7ac63e..347393c3d 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -197,12 +197,13 @@ class BGExtract(BibleCommon): Chapter number """ log.debug(u'get_bible_chapter %s, %s, %s', version, bookname, chapter) - 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) - log.debug(u'BibleGateway url = %s' % urlstring) + url = urlstring.replace(u' ', u'%20') + log.debug(u'BibleGateway url = %s' % url) # 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(url) Receiver.send_message(u'openlp_process_events') soup = BeautifulSoup(page) Receiver.send_message(u'openlp_process_events') From 3ea6ce95203c09b6ce552e9fc2d3f77f12f39106 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 24 Jul 2010 15:03:04 +0100 Subject: [PATCH 2/2] Use urllib.urlencode() --- openlp/plugins/bibles/lib/http.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 347393c3d..43c9cf405 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -24,10 +24,11 @@ ############################################################################### import logging -import urllib2 import os -import sqlite3 import re +import sqlite3 +import urllib +import urllib2 from BeautifulSoup import BeautifulSoup, Tag, NavigableString @@ -197,13 +198,14 @@ class BGExtract(BibleCommon): Chapter number """ log.debug(u'get_bible_chapter %s, %s, %s', version, bookname, chapter) - urlstring = u'http://www.biblegateway.com/passage/?search=%s %s' \ - u'&version=%s' % (bookname, chapter, version) - url = urlstring.replace(u' ', u'%20') - log.debug(u'BibleGateway url = %s' % url) + url_params = urllib.urlencode( + {u'search': u'%s %s' % (bookname, chapter), + u'version': u'%s' % version}) # 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(url) + page = urllib2.urlopen( + u'http://www.biblegateway.com/passage/?%s' % url_params) + log.debug(u'BibleGateway url = %s' % page.geturl()) Receiver.send_message(u'openlp_process_events') soup = BeautifulSoup(page) Receiver.send_message(u'openlp_process_events')