Hello, I'm trying to use webkit to analyze the webpage in background process. The problem is that I can't find a way to get all HTTP headers obtained with response.
For example, I'm looking the following ability:
import webkit
def resource_load_finished( self, frame, resource):
# here I can easily get the data (HTML/CSS/JS/etc. document body)
data = resource.get_data()
# and now I want some similar way to get the headers
headers = resource.get_all_response_headers()
b = webkit.WebView()
b.connect( 'resource-load-finished', resource_load_finished)
BTW, googling, reading documentation and so on gives me no answer how to do that. Initially I wanted to rely on a NetworkResponse object and it's "message" property, but always got an error, that "message" attribute not found for webkit.NetworkResponse object. Despite the fact that help(webkit.NetworkResponse) produces the following output:
class NetworkResponse(gobject._gobject.GObject)
| Object WebKitNetworkResponse
|
| Properties from WebKitNetworkResponse:
| uri -> gchararray: URI
| The URI to which the response will be made.
| message -> SoupMessage: Message
| The SoupMessage that backs the response.
I found that in reality there is no binding to the message property or "webkit_network_response_get_message (WebKitNetworkResponse *response);" method implemented. Therefore I don't know if "message" is a good way to get what I need (I only assume that it could contain all the network message including both headers and body).
Please, let me know if what I need could be achieved with pywebkitgtk.
Thank you in advance,
Mike