Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to read HTML document cookie?



  • Hi ,its my second post for the day,here is what I am trying to do
    I am accessing a webpage using POST method (using QNetworkAccessManager) ,now in response the html source have a javascript which sets the documents cookie ,I want to extract this cookie here ishow the html looks

    <html>     
    <script type="text/javascript">
                    document.cookie="this is the data i want to extract"
    </script>
    </html>
    

    Do anyone knows a good way to do this in QT like parsing the DOM

    Thanks

    EDIT (17 dec 2018)

    For future if somebody have a similar problem that they don't want to execute the javascript or run any web engine to parse the html content here is how I did..

    1)Use QTextStream and load the html containt into it.
    2)Read each line and conditionally check
    3) if the line contains the string "document.cookie=" using QString::contains() function
    4) when found replace the string and the ending part i.e.. ";" using QString::replace() function


Log in to reply