Pyside Qwebview And Downloading Unsupported Content
Below is the code for a minimal browser using PySide for demoing webapps and the like. It generally functions as I'd like though I can't quite seem to get my head around how to suc
Solution 1:
With a fair bit of help a solution was found. For those who might be interested, the final versions of the download and finished function are as follows:
def download(self, reply):
self.request = reply.request()
self.request.setUrl(reply.url())
self.reply = self.manager.get(self.request)
def finished(self):
path = os.path.expanduser(
os.path.join('~',
unicode(self.reply.url().path()).split('/')[-1]))
if self.reply.hasRawHeader('Content-Disposition'):
cnt_dis = self.reply.rawHeader('Content-Disposition').data()
if cnt_dis.startswith('attachment'):
path = cnt_dis.split('=')[1]
destination = QtGui.QFileDialog.getSaveFileName(self, "Save", path)
if destination:
f = open(destination[0], 'wb')
f.write(self.reply.readAll())
f.flush()
f.close()
Post a Comment for "Pyside Qwebview And Downloading Unsupported Content"