• 5020阅读
  • 1回复

读url转换为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();
}
本机建立了一个服务器,编写了一个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中的所有内容。

离线XChinux

只看该作者 1楼 发表于: 2011-04-26
用QNetworkAccessManager的get()方法来获取吧。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个