Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python Getting Very Strage Data, how to decode (requests)

I use:

import time,requests

ts = str(int(time.time()))
         
s = requests.session()

payload = {"email": "jacquelinehoffm.s0.51993@gmail.com","timestamp":ts}

headers = {
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0;Win64) AppleWebkit/536.36 (KHTML, like Gecko) Chrome/89.0.4189.82 Safari/537.16',
  'Accept-Encoding': 'gzip, deflate, br',
  'Accept-Language': 'en-US,en;q=0.9',
  'Origin': 'https://smailpro.com',
  'Referer': 'https://smailpro.com/advanced',
  'Content-Type': 'application/json'
}

r = s.post('https://smailpro.com/app/key',json=payload, headers=headers)

print(r.text)

And get something like this:

♥��^7⌂�3W►��↕�♂r��+G��"�B�7���@♀��fd{^◄��!�◄l4�↑dx2n‼Sda��bd���;L���E�♦����KG�⌂c�{↔�♫*�lӖޡ��n��l���b���k]��z[_�]|����f�ׯ�_�rs��ɭ-�↑yw��ͥ���J�♫6U���dZ?�W��Y'�M�`����=�T�♥�♀6��m1�~�♠����J�Ur��b��b→p�P��M�♫+�YC;▲
♥��W5Uƹ�@r��9o��|

how to decode this data? (it must be Object array: {code:200,items:’eyJ0eXA….iOiJKV1′,msg:’OK’})

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I check:

print(r.encoding) # it returns utf-8

I use:

with open('output.txt','w+',encoding='utf-8') as f:
  f.write(r.text) # ♥��^7⌂�......o��|

with open('output.txt','+bw',encoding='utf-8') as f:
  f.write(r.text) # error

base64:

import base64
res = base64.b64decode(r.text)
print(res) # error

encode, decode and r.content is not working

I just dont know how get data…

>Solution :

please delete this line and have another try:

'Accept-Encoding': 'gzip, deflate, br',

You asked for compressed version, But you didn’t decompress it

If it still returns the same response,It may be because the server only provides a compressed version of documentary.

Then do as follows:

Data=gzip.decompress(r.content).decode("utf-8")

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading