mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
ga - More resilient with different title/author formatting
This commit is contained in:
parent
76c2d5a545
commit
840ca8092b
@ -257,9 +257,20 @@ class Granta(BasicNewsRecipe):
|
|||||||
# Either user is logged in or the article is unlocked
|
# Either user is logged in or the article is unlocked
|
||||||
h1 = toc.find('h1')
|
h1 = toc.find('h1')
|
||||||
h2 = toc.find('h2')
|
h2 = toc.find('h2')
|
||||||
|
if h1.find('a') is not None and h1.find('a').contents is not None:
|
||||||
title = h1.find('a').contents[0].strip()
|
title = h1.find('a').contents[0].strip()
|
||||||
|
elif h1.contents[0] is not None:
|
||||||
|
title = h1.contents[0]
|
||||||
|
else:
|
||||||
|
title = ''
|
||||||
|
if h2.find('a') is not None and h2.find('a').contents is not None:
|
||||||
author = h2.find('a').contents[0].strip()
|
author = h2.find('a').contents[0].strip()
|
||||||
title = title + u' (%s)' % author
|
title = title + u' (%s)' % author
|
||||||
|
elif h2.contents[0] is not None:
|
||||||
|
author = h2.contents[0]
|
||||||
|
title = title + u' (%s)' % author
|
||||||
|
else:
|
||||||
|
author = ''
|
||||||
url = absurl(h1.find('a', href=True)['href'])
|
url = absurl(h1.find('a', href=True)['href'])
|
||||||
self.log.info('Found article:', title)
|
self.log.info('Found article:', title)
|
||||||
self.log.info('\t', url)
|
self.log.info('\t', url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user