English 中文(简体)
供制作屏幕短片的无机服务器上的投影机
原标题:Render HTML on headless server to produce screenshots

我愿从一个特定的URL制作网页的屏幕。 虽然有可能使用诸如Selenium RC之类的工具,但这需要一个制图环境。 我正在运行一个无头脑热托服务器。

这将成为诸如:

  • Fetch URL
  • Render HTML
  • Export render as image file
  • Store image file
最佳回答

xvfb,你可以提出申请。 一种简单的做法就是用Qt基调来使网页贴上网基植被,并保持图像。 http://www.blogs.uni-osnabrueck.de/rotapken/2008/12/03/create- Screenshots-of-a-web-page-using-python-and-qtwebkit/“rel=”nofollow”blog post,概述了如何用做到这一点。

这里使用的是快速指挥线工具I ve。 这是自我使用以来的一段时期,但它仍然应当发挥作用!

#include <QtCore/QCoreApplication>
#include <QtGui>
#include <QtWebKit>
#include <QTextStream>
#include <QSize>

QWebView *view;
QString outfile;

void QWebView::loadFinished(bool ok)
{
        QTextStream out(stdout);
        if (!ok) {
                out << "Page loading failed
";
                return;
        }
        view->page()->setViewportSize(view->page()->currentFrame()->contentsSize());
        QImage *img = new QImage(view->page()->viewportSize(), QImage::Format_ARGB32);
        QPainter *paint = new QPainter(img);
        view->page()->currentFrame()->render(paint);
        paint->end();
        if(!img->save(outfile, "png"))
                out << "Save failure
";
        QApplication::quit();
        return;
}

int main(int argc, char *argv[])
{
        QTextStream out(stdout);
        if(argc < 3) {
                out << "USAGE: " << argv[0] << " <url> <outfile>
";
                return -1;
        }
        outfile = argv[2];
        QApplication app(argc, argv);
        view = new QWebView();
        view->load(QUrl(argv[1]));

        return app.exec();
}
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签