Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 08-26-2022, 07:00 AM   #1
unkn0wn
Guru
unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.
 
Posts: 616
Karma: 85520
Join Date: May 2021
Device: kindle
financial times update

they changed something and each image is around 10MB.. it takes 10-15 minutes just to load all content and uses too much data and so the output file is also too large.

updated it to resize images.

change line 122 from attached recipe to return '<span><img src="{}">'.format(url)
instead of <p>.. the text before image also pertains to image.
Attached Files
File Type: recipe Financial Times - Print Edition.recipe (5.1 KB, 196 views)

Last edited by unkn0wn; 08-26-2022 at 09:57 AM.
unkn0wn is offline   Reply With Quote
Old 08-27-2022, 06:45 AM   #2
unkn0wn
Guru
unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.
 
Posts: 616
Karma: 85520
Join Date: May 2021
Device: kindle
feed based one needs changing too..

made some minor changes to both recipes.
Attached Files
File Type: recipe Financial Times.recipe (3.8 KB, 155 views)
File Type: recipe Financial Times - Print Edition.recipe (5.3 KB, 304 views)
unkn0wn is offline   Reply With Quote
Advert
Old 08-31-2022, 02:58 AM   #3
unkn0wn
Guru
unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.
 
Posts: 616
Karma: 85520
Join Date: May 2021
Device: kindle
ft cover fails
replace with this.. in both recipes
(used from telegraph recipe)
Code:
    def get_cover_url(self):
	from datetime import date
        cover = 'http://img.kiosko.net/' + str(
            date.today().year
        ) + '/' + date.today().strftime('%m') + '/' + date.today(
        ).strftime('%d') + '/uk/ft_uk.750.jpg'
        br = BasicNewsRecipe.get_browser(self)
        try:
            br.open(cover)
        except:
            index = 'https://en.kiosko.net/uk/np/ft_uk.html'
            soup = self.index_to_soup(index)
            for image in soup.findAll('img', src=True):
                if image['src'].endswith('750.jpg'):
                    return image['src']
            self.log("\nCover unavailable")
            cover = None
        return cover

Last edited by unkn0wn; 08-31-2022 at 03:04 AM.
unkn0wn is offline   Reply With Quote
Old 10-02-2022, 12:24 PM   #4
goatnix
Junior Member
goatnix doesn't littergoatnix doesn't litter
 
Posts: 3
Karma: 158
Join Date: Oct 2022
Device: Kobo Sage
I kept getting an SSL error:
Spoiler:

Using user agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36
Could not download cover: <urlopen error [SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:997)>
Traceback (most recent call last):
File "<string>", line 31, in get_cover_url
File "/usr/lib/python3.10/site-packages/mechanize/_mechanize.py", line 257, in open
return self._mech_open(url_or_request, data, timeout=timeout)
File "/usr/lib/python3.10/site-packages/mechanize/_mechanize.py", line 313, in _mech_open
raise response
mechanize._response.get_seek_wrapper_class.<locals >.httperror_seek_wrapper: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/mechanize/_urllib2_fork.py", line 1236, in do_open
h.request(str(req.get_method()), str(req.get_selector()), req.data,
File "/usr/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/usr/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/usr/lib/python3.10/http/client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib/python3.10/ssl.py", line 1071, in _create
self.do_handshake()
File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/calibre/calibre/web/feeds/news.py", line 1327, in _download_cover
cu = self.get_cover_url()
File "<string>", line 34, in get_cover_url
File "/usr/lib/calibre/calibre/web/feeds/news.py", line 707, in index_to_soup
with closing(open_func(url_or_raw, timeout=self.timeout)) as f:
File "/usr/lib/python3.10/site-packages/mechanize/_mechanize.py", line 241, in open_novisit
return self._mech_open(
File "/usr/lib/python3.10/site-packages/mechanize/_mechanize.py", line 287, in _mech_open
response = UserAgentBase.open(self, request, data)
File "/usr/lib/python3.10/site-packages/mechanize/_opener.py", line 193, in open
response = urlopen(self, req, data)
File "/usr/lib/python3.10/site-packages/mechanize/_urllib2_fork.py", line 425, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/usr/lib/python3.10/site-packages/mechanize/_urllib2_fork.py", line 414, in _call_chain
result = func(*args)
File "/usr/lib/calibre/calibre/utils/browser.py", line 28, in https_open
return self.do_open(conn_factory, req)
File "/usr/lib/python3.10/site-packages/mechanize/_urllib2_fork.py", line 1240, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:997)>


So I rewrote the cover section of the recipe to account for no cover on Sundays for the FT:

Code:
    def get_cover_url(self):
        from datetime import date, timedelta
        coverdate = date.today()
        if coverdate.weekday() == 6:
            coverdate = coverdate - timedelta(days = 1)
        cover = 'http://img.kiosko.net/' + str(
                    coverdate.year
                ) + '/' + coverdate.strftime('%m') + '/' + coverdate.strftime('%d') + '/uk/ft_uk.750.jpg'
        return cover
goatnix is offline   Reply With Quote
Old 10-02-2022, 02:55 PM   #5
unkn0wn
Guru
unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.
 
Posts: 616
Karma: 85520
Join Date: May 2021
Device: kindle
actually this will work.

Code:
    def get_cover_url(self):
        from datetime import date
        cover = 'https://img.kiosko.net/' + str(
            date.today().year
        ) + '/' + date.today().strftime('%m') + '/' + date.today(
        ).strftime('%d') + '/uk/ft_uk.750.jpg'
        br = BasicNewsRecipe.get_browser(self)
        try:
            br.open(cover)
        except:
            index = 'https://en.kiosko.net/uk/np/ft_uk.html'
            soup = self.index_to_soup(index)
            for image in soup.findAll('img', src=True):
                if image['src'].endswith('750.jpg'):
                    return 'https:' + image['src']
            self.log("\nCover unavailable")
            cover = None
        return cover
I saw this problem and made these changes for scmp recipe recently.. thought i'd do ft later and forgot.
unkn0wn is offline   Reply With Quote
Advert
Old 10-02-2022, 04:20 PM   #6
goatnix
Junior Member
goatnix doesn't littergoatnix doesn't litter
 
Posts: 3
Karma: 158
Join Date: Oct 2022
Device: Kobo Sage
I'm still getting the same error with that change for some reason, SSL wrong signature type
goatnix is offline   Reply With Quote
Old 10-03-2022, 05:08 AM   #7
unkn0wn
Guru
unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.unkn0wn understands the Henderson-Hasselbalch Equation.
 
Posts: 616
Karma: 85520
Join Date: May 2021
Device: kindle
Is this the same error type?

https://www.mobileread.com/forums/sh...72&postcount=2

Quote:
this is SSLCertVerificationError.

you can fix this by visiting the cited image link in internet explorer or edge. (its working)

Spoiler:
Could not fetch image https://resources.arcamax.com/newspi...01/2350141.gif
Traceback (most recent call last):
File "mechanize\_urllib2_fork.py", line 1236, in do_open
File "http\client.py", line 1282, in request
File "http\client.py", line 1328, in _send_request
File "http\client.py", line 1277, in endheaders
File "http\client.py", line 1037, in _send_output
File "http\client.py", line 975, in send
File "http\client.py", line 1454, in connect
File "ssl.py", line 512, in wrap_socket
File "ssl.py", line 1070, in _create
File "ssl.py", line 1341, in do_handshake
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)


https://www.mobileread.com/forums/sh...58&postcount=5
maybe it worked for me because I visited this link in edge. (I don't think I did cause I use firefox mostly)

did you somehow visit the http link type for it to work?

I suggested the above changes so that it will work even when ft isn't published on weekdays or cover isn't updated in kiosko website.

In the above changes i used https, make it http.. maybe this will work.

Spoiler:
Code:
    def get_cover_url(self):
        from datetime import date
        cover = 'http://img.kiosko.net/' + str(
            date.today().year
        ) + '/' + date.today().strftime('%m') + '/' + date.today(
        ).strftime('%d') + '/uk/ft_uk.750.jpg'
        br = BasicNewsRecipe.get_browser(self)
        try:
            br.open(cover)
        except:
            index = 'https://en.kiosko.net/uk/np/ft_uk.html'
            soup = self.index_to_soup(index)
            for image in soup.findAll('img', src=True):
                if image['src'].endswith('750.jpg'):
                    return 'http:' + image['src']
            self.log("\nCover unavailable")
            cover = None
        return cover


I think if datetime method wont return image.. it should go to kiosko site and find that image.

Or this would be much better,
Code:
    def get_cover_url(self):
        soup = self.index_to_soup('https://en.kiosko.net/uk/np/ft_uk.html')
        for image in soup.findAll('img', src=True):
            if image['src'].endswith('750.jpg'):
                return 'https:' + image['src']
            self.log("\nCover unavailable")
            cover = None
        return cover

Last edited by unkn0wn; 10-03-2022 at 05:25 AM.
unkn0wn is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Financial times update kiklop74 Recipes 0 08-20-2017 02:38 PM
Financial Times (UK) and Financial Times (International) recipes are broken mattyb Recipes 1 09-05-2014 10:49 AM
Financial Times (UK) Update rainrdx Recipes 1 04-05-2013 10:02 PM
Financial Times St28 Calibre 2 07-05-2011 10:50 AM
Update Financial Times recipe sir-archimedes Recipes 0 04-24-2011 10:39 AM


All times are GMT -4. The time now is 01:18 PM.


MobileRead.com is a privately owned, operated and funded community.