From 5ea4cff4ecde41c96f73d333dd665d4276129794 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Wed, 1 Aug 2018 19:31:08 +0530 Subject: [PATCH] Make bs4 a common import --- buku.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/buku.py b/buku.py index a95323a..6ba9cda 100755 --- a/buku.py +++ b/buku.py @@ -18,6 +18,7 @@ # along with Buku. If not, see . 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)