I need to get title of webpage
Solved
General and Desktop
-
Hi
I need to get title of webpage , for example : https://forum.qt.io/category/10/general-and-desktop , title : General and Desktop | Qt Forum .
How can i do?
Thanks -
@Armin You mean you want to extract title from:
<head> <title>General and Desktop | Qt Forum</title>
right?
Then you can just sent a GET request using http://doc.qt.io/qt-5/qnetworkaccessmanager.html and then parse the response (you can use a regular expression to extract the title from <title>...</title>).
From the link above:QNetworkRequest request; request.setUrl(QUrl("http://qt-project.org")); request.setRawHeader("User-Agent", "MyOwnBrowser 1.0"); QNetworkReply *reply = manager->get(request); connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError(QNetworkReply::NetworkError))); connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));