This article mainly introduces how to use PyQt in Python to convert webpages into PDF operation code instances. This article provides the implementation code directly. if you need it, you can refer to the code below, which is very simple and the function is very simple = w =
Webpage2pdf
#! /Usr/bin/env python3 import sys try: from PyQt4 import QtWebKit from PyQt4.QtCore import QUrl from PyQt4.QtGui import QApplication, qprinterlace T ImportError: from PySide import QtWebKit from PySide. qtCore import QUrl from PySide. qtGui import QApplication, QPrinter app = QApplication (sys. argv) def done (status): p = QPrinter () p. setOutputFormat (QPrinter. pdfFormat) p.setOutputFileName('a.pdf ') view. print (p) app. exit () view = QtWebKit. QWebView () view. load (QUrl ('http: // lilydjwg.is-programmer.com/') view. loadFinished [bool]. connect (done) # PySide does not have QApplication.execapp.exe c _()
Note: Although there is no graphical interface, you still need to connect X ......