PIL - are there a any PIL solutions that will allow you to take a screenshot of a specified web page?
Is there a way to take a screenshot using PIL of an specified HTM开发者_JAVA百科L/Javascript page that resides on my server?
I want to write a script that will change some parameters on that HTML page and then have PIL take screenshots of it.
Any ideas? Examples would be truly appreciated.
Do you absolutely have to use PIL? If not you might be able to get what you want using PyQT which has a built-in Webkit control.
See http://notes.alexdong.com/xhtml-to-pdf-using-pyqt4-webkit-and-headless for an example which converts html+css into a PDF without using a separate browser. The code is pretty short so I've copied it below.
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("http://www.google.com"))
#web.show()
printer = QPrinter()
printer.setPageSize(QPrinter.A4)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName("file.pdf")
def convertIt():
web.print_(printer)
print "Pdf generated"
QApplication.exit()
QObject.connect(web, SIGNAL("loadFinished(bool)"), convertIt)
sys.exit(app.exec_())
精彩评论