How to programmatically run a POST request in python using a graphical interface? (spynner, webkit ...)

I have a website with forms that I need to clear. Instead of filling out flash forms, I would like to POST add a few keys / values ​​to a URL that does not support GET requests.

I use spynner to interact with the site, and spynner may have a GUI , but my search on google, stackoverflow, spynner github and in the spynner module were unsuccessful.

If spynner cannot execute the POST request, maybe gtk or qt + webkit can do this? Any real-life code sample will be truly appreciated.

+6
source share
1 answer

You can do this with Spynner:

 import spynner from PyQt4.QtCore import QUrl from PyQt4.QtNetwork import QNetworkRequest, QNetworkAccessManager url = "http://localhost:8080/niklas/test.php" data = "foo=bar" headers = { "Content-Type": "application/x-www-form-urlencoded" } req = QNetworkRequest(QUrl(url)) for k, v in headers.items(): req.setRawHeader(k, v) browser = spynner.Browser() browser.webframe.load(req, QNetworkAccessManager.PostOperation, data) browser._wait_load() print browser.html 
+5
source

Source: https://habr.com/ru/post/915560/


All Articles