0

I am using a QWebView to load as website, then I grab the currentFrame() from it. After that I attempt to get a div with the class of comment-text. Here is the way I did this: Partial Input HTML:

<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>

And here's the relevant code:

    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'

1 Answer 1

2

am using a QWebView to load as website, then I grab the currentFrame() from it. After that I attempt to get a div with the class of comment-text.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.