View Single Post
Old 04-17-2015, 01:52 PM   #18
hegi
Enthusiast
hegi began at the beginning.
 
Posts: 44
Karma: 10
Join Date: Dec 2012
Device: Kindle 4 & Kindle PW 3G
Dear Kovid,

thanks for your quick reply. - However, as it appears, I still dont't get it right.

I took your snippet and made from it this:

Code:
    cover_source          = 'https://kaufhaus.handelsblatt.com/downloads/wirtschaftswoche-emagazin-p1952.html'

    def get_cover_url(self):
        cover_source_soup = self.index_to_soup(self.cover_source)
        style = soup.find('img', alt='WirtschaftsWoche eMagazin', style=True)['style']
        self.cover_url = style.partition('(')[-1].rpartition(')')[0]
        return self.cover_url
But when I look into the log of the recipe I get:

Quote:
[Cover could not be downloaded]: global name 'soup' is not defined
Traceback (most recent call last):
File "site-packages/calibre/web/feeds/news.py", line 1263, in _download_cover
File "<string>", line 49, in get_cover_url
NameError: global name 'soup' is not defined
Line 49 is your "style = soup.find ... "line.

As far as my limited understanding of these issues goes, I have to embedd this code somehow into an "def ... return ..." section. But maybe your suggestion was meant in a different way?

Thanks again.

Hegi.
hegi is offline   Reply With Quote