2016-07-21 7 views
0

QWebViewを使用してWebサイトとして読み込み、currentFrame()を取得します。その後、私はcomment-textのクラスでdivを取得しようとします。ここで私はこれをしなかった方法は次のとおりです。 部分入力HTML:QWebFrameのfindAllElements()からの出力が得られません。

<div class="content"> 
    <span class="byline"> 
    <span class="author"> 
    <span aria-label="Verified" class="yt-channel-title-icon-verified yt-uix-tooltip yt-sprite" data-tooltip-text="Verified"></span> 
    <span class="badges"> 
    <span aria-label="Owner" class="yt-chat-badge badge-owner yt-uix-tooltip yt-sprite" data-tooltip-text="Owner"></span> 
    <span aria-label="Moderator" class="yt-chat-badge badge-moderator yt-uix-tooltip yt-sprite" data-tooltip-text="Moderator"></span> 
    <span aria-label="Sponsor" class="yt-chat-badge badge-member yt-uix-tooltip yt-sprite" data-tooltip-text="Sponsor"></span> 
    </span> 
    <a href="https://gaming.youtube.com/channel/UCY88BS-9dTTHl7As46eFyuw" class="yt-uix-sessionlink yt-user-name" data-sessionlink="ei=pUqQV8j6N4rWuQLQmZ3AAQ" data-ytid="UCY88BS-9dTTHl7As46eFyuw" dir="ltr" data-name="">Andres Casanovas</a> 
    </span> 
    </span> 
    <div class="comment-text" dir="ltr"> 
     he needs thorn 
    </div> 
    <div class="deleted-message-text"> 
    </div> 
    <div class="inline-error inline-message"> 
     Message not sent: <span class="inline-error-message"></span> 
    </div> 
    <div class="inline-moderator-message inline-message"></div> 
</div> 

そして、ここでは、関連するコードがあります:

YouTubeWebview = new QWebView(); 
    QEventLoop YouTubePageLoop1; 
    connect(YouTubeWebview, SIGNAL(loadFinished(bool)), &YouTubePageLoop1, SLOT(quit())); 
    connect(YouTubeWebview, SIGNAL(loadFinished(bool)), this, SLOT(YouTubeWebview_finishedLoading(bool))); 
    YouTubeWebview->load(QUrl("live_stream_url")); 
    YouTubePageLoop1.exec(); 
    YouTubeWebview->show(); 
    QWebElementCollection elements = YouTubeWebview->page()->currentFrame()->findAllElements("div.comment-text"); 
    qDebug() << elements.count();//Outputs '0' 

答えて

2

はその後、私は(に、currentFrameをつかむ、Webサイトとして読み込むためにQWebViewを使用しています)からそれ。その後、私はcomment-textのクラスでdivを取得しようとします。

関連する問題