QWebPage не загружает документ из LINK

В моем проекте с Qt, когда я нажимаю на ссылку для загрузки файла, у меня есть один файл, подобный этому:

Value cannot be null.
Parameter name: fileContents

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

В моем коде у меня есть:

self.setForwardUnsupportedContent(True)
self.unsupportedContent.connect(self.download)    
self.manager = QtNetwork.QNetworkAccessManager()
self.manager.finished.connect(self.finished)

а также:

def download(self, reply):
        self.request = QtNetwork.QNetworkRequest(reply.url())
        self.reply = self.manager.get(self.request)
        logMessage(u"{}".format(reply.url()))

def finished(self):
        path = os.path.expanduser(os.path.join('~', unicode(self.reply.url().path()).split('/')[-1]))#C:\Users\user\GetExcel\

        path="C:\\Users\\GIUS\\sdfds\\asdas.xls"
        try:
            #destination = QFileDialog.getSaveFileName(self.webView, "Save", path)
            filename = path#destination #[0]
            logMessage("{}".format(filename))
            with open(filename, 'wb') as f:
                f.write(str(self.reply.readAll()))
                f.close()
        except Exception as e:
            logMessage("ERROR QFileDialog {} ERROR:{}".format(path,e))

0 ответов

Другие вопросы по тегам