Python converts a webpage into a PDF code instance using pythonpyqt

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.