Question

I would like to automate the process of filling out a form on the web, sending a request, and processing the resulting page over and over again (with different inputs).

I'm able to access the page using QWebPage / connect (with a method that waits for the loadFinished signal). I can traverse the fields and fill in values using QWebPage, QWebElement's firstChild, nextSibling, and setPlainText methods.

However, I'm kind of stuck as to how to submit the information and retrieve the response to the post request. From online tutorials, it looks like I can use evaluateJavaScript() to click a submit button, but I don't see how to get/refresh the page resulting from the post submission. (note the content type is multipart/form-data, and the post request is sent to a php script). It also looks like using the QNetworkRequest class might have the functionality to do this, but I'm unclear on how.

Was it helpful?

Solution

It seems like sending a POST with QNetworkAccessManager to the appropriate URL may accomplish this for you. You will need to send the contents as a QByteArray or QIODevice.

Also, take a look at this Stack Overflow post, for a potential example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top