Python converts a webpage into a PDF code instance using pythonpyqt
The code 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 ......