From b2238e10e7c966115161fa759fc445d2b2b4b67a Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 22 Oct 2015 18:16:30 -0500 Subject: [PATCH] Add html5lib to more BS4 calls, convert another place to BS4. --- fanficfare/epubutils.py | 4 ++-- fanficfare/geturls.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fanficfare/epubutils.py b/fanficfare/epubutils.py index 9798a71..5c2f632 100644 --- a/fanficfare/epubutils.py +++ b/fanficfare/epubutils.py @@ -57,7 +57,7 @@ def get_update_data(inputio, if( relpath+item.getAttribute("href") == oldcoverhtmlhref ): oldcoverhtmltype = item.getAttribute("media-type") break - soup = bs.BeautifulSoup(oldcoverhtmldata.decode("utf-8")) + soup = bs.BeautifulSoup(oldcoverhtmldata.decode("utf-8"),"html5lib") src = None # first img or image tag. imgs = soup.findAll('img') @@ -208,7 +208,7 @@ def get_story_url_from_html(inputio,_is_good_url=None): #print("---- item:%s"%item) if( item.getAttribute("media-type") == "application/xhtml+xml" ): filehref=relpath+item.getAttribute("href") - soup = bs.BeautifulSoup(epub.read(filehref).decode("utf-8")) + soup = bs.BeautifulSoup(epub.read(filehref).decode("utf-8"),"html5lib") for link in soup.findAll('a',href=re.compile(r'^http.*')): ahref=link['href'] #print("href:(%s)"%ahref) diff --git a/fanficfare/geturls.py b/fanficfare/geturls.py index dd09e9f..9a7434c 100644 --- a/fanficfare/geturls.py +++ b/fanficfare/geturls.py @@ -25,7 +25,7 @@ import urlparse import logging logger = logging.getLogger(__name__) -from BeautifulSoup import BeautifulSoup +from bs4 import BeautifulSoup from gziphttp import GZipProcessor import adapters @@ -82,7 +82,7 @@ def get_urls_from_html(data,url=None,configuration=None,normalize=False,restrict if not configuration: configuration = Configuration("test1.com","EPUB") - soup = BeautifulSoup(data) + soup = BeautifulSoup(data,"html5lib") if restrictsearch: soup = soup.find(*restrictsearch) #logger.debug("restrict search:%s"%soup)