Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Download full web page
QtWS25 Last Chance

Download full web page

Scheduled Pinned Locked Moved Solved QtWebEngine
qtwebenginepython3
7 Posts 4 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Black CatB Offline
    Black CatB Offline
    Black Cat
    wrote on last edited by
    #1

    Hi guys, it's possible to download a full web page with the QtWebEngine (Python3)?

    JKSHJ 1 Reply Last reply
    0
    • Black CatB Black Cat

      @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
                  )
      

      5ece1394-1ead-4ed5-b9bc-c3ba5f0b2f06-image.png

      M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #6

      @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 CatB 1 Reply Last reply
      2
      • Black CatB Black Cat

        Hi guys, it's possible to download a full web page with the QtWebEngine (Python3)?

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #2

        @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.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        Black CatB 1 Reply Last reply
        3
        • JKSHJ JKSH

          @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 CatB Offline
          Black CatB Offline
          Black Cat
          wrote on last edited by
          #3

          @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)?
          0ec276ca-f1bd-49a7-ba09-27074bc8eaf5-image.png

          JonBJ 1 Reply Last reply
          0
          • Black CatB Black Cat

            @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)?
            0ec276ca-f1bd-49a7-ba09-27074bc8eaf5-image.png

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @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.save

            This 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 CatB 1 Reply Last reply
            0
            • JonBJ JonB

              @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.save

              This 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 CatB Offline
              Black CatB Offline
              Black Cat
              wrote on last edited by Black Cat
              #5

              @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
                          )
              

              5ece1394-1ead-4ed5-b9bc-c3ba5f0b2f06-image.png

              M 1 Reply Last reply
              0
              • Black CatB Black Cat

                @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
                            )
                

                5ece1394-1ead-4ed5-b9bc-c3ba5f0b2f06-image.png

                M Offline
                M Offline
                mpergand
                wrote on last edited by mpergand
                #6

                @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 CatB 1 Reply Last reply
                2
                • M mpergand

                  @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 CatB Offline
                  Black CatB Offline
                  Black Cat
                  wrote on last edited by
                  #7

                  @mpergand Thank you man =)

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved