pythonseleniumbase64browsermob-proxyhar

How to decode request content from BrowserMobProxy's har?


I'm trying to get some data from facebook by using python3, seleniumwire, haralyzer, chromedriver and browsermobproxy.

When I run broswermobproxy with that options:

har_options = {'captureHeaders': True, 'captureContent': True, 'captureBinaryContent': True}
self.proxy.new_har("new_members_answers", har_options)

I get a response with that content text:

request

When I decode it from base64:

import base64

content_dec = base64.b64decode(content)

I get this:

request

I would be very grateful if you tell me how to convert it to text (json data) - like in browser DevTools.


Edit

The encoded text:

B+IXAGTepr3dczlpvaWNHRUEKN29j51k9YQQtmjClMGw7//fWmq5aEw9G0PS3v8zk/eWAsi7V+AFKiLKq0yrokxJVVUTSCBhGFRkmYQQkfKE7mO05D5jYZCCP10p/v8dAKAznSW58wO4whHy9q/yPRw70wWvTR7xGQtiRyg0Sdy3j9xYk+7mMPudH0AHYct2CHYRdRkitPORKisVidpr/naE07ZWednIBmgwMZ6WDeiCZS6iPyoIA1IDDUxkYi1VKVi3yImaGReyNCRAwmjOJ/awCrkzLT35SEXRhfZobxAhxHYRQ7Bz7cW3eoVMTALXnriC813ihjdj0fkB/F6VDmoaJuyvXW4yk5papBo9SMlKhdTUsEZUfucwNL591HYc2YgwNXXRKpAKkBnZ/lFBBGkZVZWXJKYoudk6tMdpKXZvFfKZm9RMlxkXUsT7pHmiqxwSxA5oHtgoOUPqEmlrXUSmLjB2xzbykSgF8A1dMRZmZpFsVao/EdbO9ZEgmKaVeMuRpHzePjiBl3KlZesJMC3PSuVoR0LhePQqVH2kj/60PJG3Zb0o7J6UPrIfALV28B0G1mlIGR5HbnxVviqJuuloxCi2yCgowdSTB4tNkSo5S0h/bFVWKkBfyrPnyIdO81F+iNy3mEQdMiRVua4j61mWWWTkKn7Cxy70glrUpIt7QSp6gSf91J//N/n6vkQ92EXfZxS+Kfye2BZ2XAY5htQhDNkOwtRilHGLWBYj2GHEsQi0XAdaPO2F2eNXnkouRfkzguQfPJXcyJ/7+/j4DuPh0EWvnRs8NFzEi0SZ8bXbXBa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mHs+6U6NPoVPLoHE93k7Ny0/lpaQYZ0rvCzul+cc+CGLbO8RFZ3tt/OfUkyt/s+lB21Y787XEdXmrIgi62np8bDBcUQxKqIn2VHUxR1ma83Esm0l9CWzhIqGW79rbIpTbHQz8PTodChKCNKLEohQuvGM0WPNr3S29M23p1PH6Wn1cv+br08cUJ3157P09vKj2sxnYkv26f2wE6p6/JSCSPgT0eYwlVZtKWnq8EsX2imEsIojhwfAe7kCoiFPyqRsOB445dcOdC7Bs6GlMrwXX5kpNF5bWmkfZgd/OIyqIwHop82wtSi7ZySUlYJSSx0XOetSIRZSNbiqK92LPmOtKktTxGb16g2uggFxEoslzJph3qW5Ma+QxxrlHceHa6msFueJ3TboDDYBGxRjxZPL7M6kfgkfXh/jgtRg9v3vQPl9PK/hzCOT3exl40i5IrruPZwTiH53YON8lxJdbDwWgP2g/qIefVycRD8d9vx8hLFHWeouAj1jmelA0n7/nHMhGV+py+K3X6Crb78nFrV74azNLM6X42V87MdhQ2M+d9xfZqP0B0cpugDZvfu614oaLi2E3GktuEyIK9Zpdo1n+t+6sDW73aUfy574D6oNFk5lxwIgKGWoDYitbb0fjQP20PGgCj5fdrUXnSJEmV6rI5hn9XvND5/Yi4wseomQVlzCzQqYg9jqLjl8WDT37wrPEnMGBpUd99MwAD

Solution

  • it caused by brotli compression.

    $ pip3 install brotli
    

    in py file

    import brotli
    import base64
    
    decoded_text = brotli.decompress(
    base64.b64decode(entryProxy['response']['content']['text'])
    ).decode()