Html Parsing with QtWebEngine
-
If the site use XHTML you can use the XML classes to achieve what you want.
-
Hello,
QNetworkAccessManager, QNetworkRequest, QNetworkReply libraries can be used for getting the content of a web page as I have seen from the web. By the help of them I could get the source of the web page into a QString object. But I want to get the button of a web page into my application. (May be this can be similar to parse the title of a web page from the source and show it on the app) How can I parse the source according to tag names? Thank you in advance. -
@aysenur
Parsing HTML (not XHTML) is notoriously difficult. There is not a built-in Qt offering.However, see the discussion and posted answer at https://forum.qt.io/topic/74485/is-there-a-clear-way-to-parse-html-in-qt-5-7/14. It appears there is a
QGumboParser
(https://github.com/lagner/QGumboParser) which someone is reporting success with under Qt.Otherwise, you'll have to see whether your particular use case can be addressed to your limited satisfaction via Regular Expression parsing from Qt.