mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-19 15:13:22 +02:00
Update New York Review of Books
This commit is contained in:
parent
8e73b8efef
commit
38fd76c21b
2 changed files with 14 additions and 6 deletions
|
|
@ -13,6 +13,11 @@
|
|||
def find_header(tag):
|
||||
return tag.name == 'header' and tag.parent['class'] == 'article'
|
||||
|
||||
def absurl(url):
|
||||
if url.startswith('/'):
|
||||
url = 'http://www.nybooks.com' + url
|
||||
return url
|
||||
|
||||
class NewYorkReviewOfBooks(BasicNewsRecipe):
|
||||
|
||||
title = u'New York Review of Books'
|
||||
|
|
@ -64,7 +69,7 @@ def parse_index(self):
|
|||
sidebar = soup.find('div', attrs={'class':'issue_cover'})
|
||||
if sidebar is not None:
|
||||
img = sidebar.find('img', src=True)
|
||||
self.cover_url = 'http://www.nybooks.com' + img['src']
|
||||
self.cover_url = absurl(img['src'])
|
||||
self.log('Found cover at:', self.cover_url)
|
||||
|
||||
# Find date
|
||||
|
|
@ -84,7 +89,7 @@ def parse_index(self):
|
|||
title = self.tag_to_string(h2).strip()
|
||||
author = self.tag_to_string(div.find('div', attrs={'class':'author'})).strip()
|
||||
title = title + u' (%s)'%author
|
||||
url = 'http://www.nybooks.com' + h2.find('a', href=True)['href']
|
||||
url = absurl(h2.find('a', href=True)['href'])
|
||||
desc = ''
|
||||
for p in div.findAll('p', attrs={'class':lambda x: x and 'quiet' in x}):
|
||||
desc += self.tag_to_string(p)
|
||||
|
|
@ -95,4 +100,3 @@ def parse_index(self):
|
|||
'description':desc})
|
||||
|
||||
return [('Current Issue', articles)]
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@
|
|||
def find_header(tag):
|
||||
return tag.name == 'header' and tag.parent['class'] == 'article'
|
||||
|
||||
def absurl(url):
|
||||
if url.startswith('/'):
|
||||
url = 'http://www.nybooks.com' + url
|
||||
return url
|
||||
|
||||
class NewYorkReviewOfBooks(BasicNewsRecipe):
|
||||
|
||||
title = u'New York Review of Books (no subscription)'
|
||||
|
|
@ -52,7 +57,7 @@ def parse_index(self):
|
|||
sidebar = soup.find('div', attrs={'class':'issue_cover'})
|
||||
if sidebar is not None:
|
||||
img = sidebar.find('img', src=True)
|
||||
self.cover_url = 'http://www.nybooks.com' + img['src']
|
||||
self.cover_url = absurl(img['src'])
|
||||
self.log('Found cover at:', self.cover_url)
|
||||
|
||||
# Find date
|
||||
|
|
@ -72,7 +77,7 @@ def parse_index(self):
|
|||
title = self.tag_to_string(h2).strip()
|
||||
author = self.tag_to_string(div.find('div', attrs={'class':'author'})).strip()
|
||||
title = title + u' (%s)'%author
|
||||
url = 'http://www.nybooks.com' + h2.find('a', href=True)['href']
|
||||
url = absurl(h2.find('a', href=True)['href'])
|
||||
desc = ''
|
||||
for p in div.findAll('p', attrs={'class':lambda x: x and 'quiet' in x}):
|
||||
desc += self.tag_to_string(p)
|
||||
|
|
@ -83,4 +88,3 @@ def parse_index(self):
|
|||
'description':desc})
|
||||
|
||||
return [('Current Issue', articles)]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue