#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtWebKit/QWebView>
#include <QtWebKit/QWebFrame>
#include <QtWebKit/QWebElement> int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWebView *view=new QWebView;
QWebFrame *frame=view->page()->mainFrame();
frame->load(QUrl("
http://localhost/tuangou.php"));
QString html=frame->toHtml();
qDebug()<<html;
return a.exec();
}
本机建立了一个服务器,编写了一个php文件
http://localhost/tuangou.php的内容如下
<html>
<body>
<p>First Paragraph</p>
<p>Second Paragraph</p>
</body>
</html>
程序运行打印出来的是"<html><head></head><body></body></html>"
这里面没有First Paragraph和Second Paragraph,而我想要
http://localhost/tuangou.php中的所有内容。