From 17a631dc79e0f9ba98eb02a342ea82e0a388b0be Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 21 Apr 2015 10:44:49 -0500 Subject: [PATCH] More fix for storiesonline.net change --- fanficfare/adapters/adapter_storiesonlinenet.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fanficfare/adapters/adapter_storiesonlinenet.py b/fanficfare/adapters/adapter_storiesonlinenet.py index b3d2346..a8da7c2 100644 --- a/fanficfare/adapters/adapter_storiesonlinenet.py +++ b/fanficfare/adapters/adapter_storiesonlinenet.py @@ -321,7 +321,10 @@ class StoriesOnlineNetAdapter(BaseSiteAdapter): soup = bs.BeautifulSoup(self._fetchUrl(url), selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags. - div = soup.find('article', {'id' : 'story'}) + div = soup.find('div', {'id' : 'story'}) + if not div: + logger.debug("div id=story not found, try article") + div = soup.find('article', {'id' : 'story'}) # some big chapters are split over several pages pager = div.find('span', {'class' : 'pager'}) @@ -343,7 +346,10 @@ class StoriesOnlineNetAdapter(BaseSiteAdapter): soup = bs.BeautifulSoup(self._fetchUrl("http://"+self.getSiteDomain()+ur['href']), selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags. - div1 = soup.find('article', {'id' : 'story'}) + div1 = soup.find('div', {'id' : 'story'}) + if not div1: + logger.debug("div id=story not found, try article") + div1 = soup.find('article', {'id' : 'story'}) # Find the "Continues" marker on the current page and remove everything after that. continues = div.find('span', {'class' : 'conTag'}) @@ -401,14 +407,17 @@ class StoriesOnlineNetAdapter(BaseSiteAdapter): # For a story or the last chapter, remove voting form and the in library box a = div.find('div', {'id' : 'vote-form'}) + if a != None: + a.extract() + a = div.find('div', {'id' : 'top-header'}) if a != None: a.extract() a = div.find('div', {'id' : 'b-man-div'}) if a != None: a.extract() - # Kill the "The End" header and everything after it. - a = div.find(['h2', 'h3'], {'class' : 'end'}) + # Kill the vote form and everything after it. + a = div.find('div', {'class' : 'vform'}) logger.debug("Chapter end= '{0}'".format(a)) while a != None: b = a.nextSibling