On the theory that the Kobo browser is probably using some ancient version of WebKit, I tried out the mobile page with the version of WebKit bundled with calibre, which is also pretty ancient, but downloading works fine there. See attached script which can be run with calibre-debug and will save the downloaded file as raw.epub in the current directory
Code:
from __future__ import absolute_import, division, print_function, unicode_literals
from PyQt5.Qt import *
class Page(QWebPage):
def __init__(self, p):
QWebPage.__init__(self, p)
self.setForwardUnsupportedContent(True)
self.downloadRequested.connect(self.download_requested)
self.unsupportedContent.connect(self.unsupported_content)
def javaScriptConsoleMessage(self, msg, lineno, msgid):
print(msg, lineno, msgid)
def unsupported_content(self, reply):
self.reply = r = reply
r.error.connect(self.on_error)
r.finished.connect(self.on_finish)
def download_requested(self, request):
self.unsupported_content(self.networkAccessManager().get(request))
def on_finish(self):
with open('raw.epub', 'wb') as f:
f.write(self.reply.readAll())
def on_error(self, error):
print('error:', error)
app = QApplication([])
w = QWebView()
page = Page(w)
w.setPage(page)
w.setUrl(QUrl('http://localhost:8080/mobile'))
w.show()
app.exec_()