Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Qt html解析未找到任何标记_C++_Html_Qt_Html Parsing - Fatal编程技术网

C++ Qt html解析未找到任何标记

C++ Qt html解析未找到任何标记,c++,html,qt,html-parsing,C++,Html,Qt,Html Parsing,我正在写一个爬行应用程序。在代码的某个地方,我得到了: //normally the HTML is obtained from web with QNetworkAccessManager & QNetworkReply: //QString htmlCode = this->reply->readAll(); //exemplary test HTML QString htmlCode =QString("<html><body><a

我正在写一个爬行应用程序。在代码的某个地方,我得到了:

//normally the HTML is obtained from web with QNetworkAccessManager & QNetworkReply:
//QString htmlCode = this->reply->readAll();  

//exemplary test HTML
QString htmlCode =QString("<html><body><a href=\'foo.bar\'>test1</a><h2>test2<h2><a href=\"bar.foo  \">test3</a></body></html>"); 
QWebPage page;
QWebFrame * frame = page.mainFrame(); //->setHtml(htmlCode);
frame->setHtml(htmlCode);
QWebElement document = frame->documentElement();
QWebElementCollection links = document.findAll("a");
foreach (QWebElement e, links) {
   qDebug() << "exemplary link:" << e.toPlainText();
}
//通常使用QNetworkAccessManager和QNetworkReply从web获取HTML:
//QString htmlCode=this->reply->readAll();
//示例性测试HTML
QString htmlCode=QString(“test2”);
QQ网页;
QWebFrame*frame=page.mainFrame();//->setHtml(htmlCode);
框架->设置HTML(htmlCode);
QWebElement文档=框架->文档元素();
QWebElementCollection links=document.findAll(“a”);
foreach(QWebElement e,链接){

qDebug()Mmm…我不确定
setHtml()
是否能完全同步工作,也就是说,我认为当时帧内容没有完全解析,因此DOM内容还不可用


您应该尝试连接到void
QWebFrame::loadFinished(bool ok)
并在那里进行DOM爬网。

Mmm…我不确定
setHtml()
是否完全同步工作,即我认为当时框架内容没有完全解析,因此DOM内容还不可用


您应该尝试连接到void
QWebFrame::loadFinished(bool ok)
并在那里进行DOM爬行。

问题出在哪里?没有元素或空格“toPlainText”?[UPD]组,标题上说了。问题出在哪里?没有元素或空格“toPlainText”?[UPD]组,标题上说了。