From 6dd5522b7acd5127a1538dac7f003b865a0eb823 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Sun, 7 Apr 2013 12:13:16 -0500 Subject: [PATCH] Include notes with chapter text for thewriterscoffeeshop.com. --- .../adapter_thewriterscoffeeshopcom.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/fanficdownloader/adapters/adapter_thewriterscoffeeshopcom.py b/fanficdownloader/adapters/adapter_thewriterscoffeeshopcom.py index 3a97c95f..9a0cc3b2 100644 --- a/fanficdownloader/adapters/adapter_thewriterscoffeeshopcom.py +++ b/fanficdownloader/adapters/adapter_thewriterscoffeeshopcom.py @@ -244,16 +244,23 @@ class TheWritersCoffeeShopComSiteAdapter(BaseSiteAdapter): # issues with different SGML parsers in python. This is a # nasty hack, but it works. data = data[data.index("') + + soup = bs.BeautifulSoup(data) + + found=False + for div in soup.findAll('div'): + if div.has_key('class') and div['class'] == 'notes': + chapter.append(div) + if div.has_key('id') and div['id'] == 'story': + chapter.append(div) + found=True + + if not found: raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url) - - return self.utf8FromSoup(url,span) + + return self.utf8FromSoup(url,chapter) def getClass(): return TheWritersCoffeeShopComSiteAdapter