I use python-browsermobproxy and python-selenium, then I set 'captureBinaryContent': True, so I can get the content, then I get the text from response, then use base64.b64decode to decode the response, the response is 'mimeType': 'application/protobuffer'
, but I can't use the decode text do use proto.ParseFromString, decode error.
I want to do like fiddler when getting the binarycontent using sesstion.utilDecodeResponse
, then the body I want decode to proto. But when I use python-browsermobproxy
and python-selenium
, I don't know how to do it, I need some help.
code:
for entry in proxy.har['log']['entries']:
_url = entry['request']['url']
_response = entry['response']
_content = _response['content']
#_content['mimeType'] is 'application/protobuffer'
_text = _content['text']#get the text ,is base64
text_dec = base64.b64decode(_text)
'''
how to decode the text_dec like fiddler utilDecodeResponse
todo
'''
I get the answer, when I check the request and response,I find the
{'name': 'content-encoding', 'value': 'br'} the text is use br compress,so when I use brotli.decompress to decompress the text ,it is ok. So you can check the content-encoding to select the decode func,like gzip br or other.