View Single Post
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