Download full web page
-
@JonB Can I use it with PyQT5? What I'm doing wrong?
try: self.wvTest.page().save( # Working (output of indexed image) filepath, format=QWebEngineDownloadItem.MimeHtmlSaveFormat # Not working # filepath, format=QWebEngineDownloadRequest.MimeHtmlSaveFormat )
@Black-Cat
First you have to register to downloadRequested(QWebEngineDownloadItem *download) signal emitted by the default profile.Then in the slot method (sorry C++ code)
void downloadRequested(QWebEngineDownloadItem *download) { if(download->isSavePageDownload()) { download->setSavePageFormat(QWebEngineDownloadItem::CompleteHtmlSaveFormat); download->accept(); } }This method is called on response to a right-click on "Save Page" in the context menu of the webview.
-
@Black-Cat said in Download full web page:
Hi guys, it's possible to download a full web page with the QtWebEngine (Python3)?
Sure, Qt WebEngine's purposes is to let you download and view webpages.
If you meant "download to disk", call the
toHtml()function (see https://doc.qt.io/qtforpython/PySide6/QtWebEngineCore/QWebEnginePage.html#PySide6.QtWebEngineCore.PySide6.QtWebEngineCore.QWebEnginePage.toHtml ) this will give you the web page as a HTML document, but you'll need to download the assets (such as images) separately. -
@Black-Cat said in Download full web page:
Hi guys, it's possible to download a full web page with the QtWebEngine (Python3)?
Sure, Qt WebEngine's purposes is to let you download and view webpages.
If you meant "download to disk", call the
toHtml()function (see https://doc.qt.io/qtforpython/PySide6/QtWebEngineCore/QWebEnginePage.html#PySide6.QtWebEngineCore.PySide6.QtWebEngineCore.QWebEnginePage.toHtml ) this will give you the web page as a HTML document, but you'll need to download the assets (such as images) separately. -
@JKSH
But it's possible to create the same signal of the button "Save Page"? Because this method will link directly the images with the source (without download the images)?

@Black-Cat
If you look on @JKSH's page there is https://doc.qt.io/qtforpython/PySide6/QtWebEngineCore/QWebEnginePage.html#PySide6.QtWebEngineCore.PySide6.QtWebEngineCore.QWebEnginePage.saveThis is a short cut for the following actions:
Trigger the Save web action.
Accept the next download item and set the specified file path and save format.
-
@Black-Cat
If you look on @JKSH's page there is https://doc.qt.io/qtforpython/PySide6/QtWebEngineCore/QWebEnginePage.html#PySide6.QtWebEngineCore.PySide6.QtWebEngineCore.QWebEnginePage.saveThis is a short cut for the following actions:
Trigger the Save web action.
Accept the next download item and set the specified file path and save format.
@JonB Can I use it with PyQT5? What I'm doing wrong?
try: self.wvTest.page().save( # Working (output of indexed image) filepath, format=QWebEngineDownloadItem.MimeHtmlSaveFormat # Not working # filepath, format=QWebEngineDownloadRequest.MimeHtmlSaveFormat )
-
@JonB Can I use it with PyQT5? What I'm doing wrong?
try: self.wvTest.page().save( # Working (output of indexed image) filepath, format=QWebEngineDownloadItem.MimeHtmlSaveFormat # Not working # filepath, format=QWebEngineDownloadRequest.MimeHtmlSaveFormat )
@Black-Cat
First you have to register to downloadRequested(QWebEngineDownloadItem *download) signal emitted by the default profile.Then in the slot method (sorry C++ code)
void downloadRequested(QWebEngineDownloadItem *download) { if(download->isSavePageDownload()) { download->setSavePageFormat(QWebEngineDownloadItem::CompleteHtmlSaveFormat); download->accept(); } }This method is called on response to a right-click on "Save Page" in the context menu of the webview.
-
@Black-Cat
First you have to register to downloadRequested(QWebEngineDownloadItem *download) signal emitted by the default profile.Then in the slot method (sorry C++ code)
void downloadRequested(QWebEngineDownloadItem *download) { if(download->isSavePageDownload()) { download->setSavePageFormat(QWebEngineDownloadItem::CompleteHtmlSaveFormat); download->accept(); } }This method is called on response to a right-click on "Save Page" in the context menu of the webview.