Unsolved Html Parsing with QtWebEngine
-
Hello,
I want to parse html of a web site and use necessary parts of it in my qt application. In VS.net there is Html Agility Pack nuget package for parsing the code. Is there any equivalent library in Qt?
Thank you. -
If the site use XHTML you can use the XML classes to achieve what you want.
-
@JohanSolo thank you for your answer. The document type of the web site is HTML. There is a library QXMLStreamReader to read XML files but I think this is not the library I need.
-
@aysenur Sorry but for non XHTML I have no idea. Maybe in the QtWebEngine module you can find something...
-
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.