• 5230阅读
  • 0回复

新手请教一个如何用qwebpage下载网页然后转为html [复制链接]

上一主题 下一主题
离线qiutong0505
 
只看楼主 倒序阅读 楼主  发表于: 2011-04-14
#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();
}
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中的所有内容。
[ 此帖被qiutong0505在2011-04-14 17:01重新编辑 ]
快速回复
限100 字节
 
上一个 下一个