Reputation: 404
I would like to be able to load a webpage URL and save images on the page to disk.
For non-images I can simply use QWebEngineView.load on the desired URL and it triggers a QWebEngineProfile.downloadRequested where I can specify a file path and accept the download. However, images just get displayed in the browser itself and bypass the downloadRequested.
It does not have to be elegant, but the page uses authentication and .load seems to pass that information around.
Upvotes: 1
Views: 1807
Reputation: 368
You can install a QWebEngineUrlRequestInterceptor
to the profile of the page before loading anything, and use QWebEngineUrlRequestInfo::resourceType()
to see if the resource being requested is an image or not. If it is an image, you can grab its URL as well from the QWebEngineUrlRequestInfo
and download it.
Upvotes: 3
Reputation: 404
Well, I found a workaround for now... in Qt 5.8, QWebEnginePage has a save function which emits a download for the currently loaded web page... so you just have to navigate to the image URL using QWebEngineView.load and then use QWebEnginePage.save
Upvotes: 1