Make bs4 a common import

This commit is contained in:
Arun Prakash Jana 2018-08-01 19:31:08 +05:30
parent 745b6190e4
commit 5ea4cff4ec
No known key found for this signature in database
GPG Key ID: A75979F35C080412

View File

@ -18,6 +18,7 @@
# along with Buku. If not, see <http://www.gnu.org/licenses/>.
import argparse
from bs4 import BeautifulSoup
import cgi
import collections
import html.parser as HTMLParser
@ -2311,9 +2312,8 @@ class BukuDb:
else:
try:
import bs4
with open(filepath, mode='r', encoding='utf-8') as infp:
soup = bs4.BeautifulSoup(infp, 'html.parser')
soup = BeautifulSoup(infp, 'html.parser')
except ImportError:
logerr('Beautiful Soup not found')
return False
@ -2960,7 +2960,6 @@ def get_page_title(resp):
parsed_title = None
try:
from bs4 import BeautifulSoup
soup = BeautifulSoup(resp.data, 'html.parser')
except Exception as e:
logerr('get_page_title(): %s', e)