What may cause the error in JSON conversion?

Asked

Viewed 67 times

2

I’m making a Crawler, which will take the GIFS from 9gag. The code is this:

In [11]: import requests                                                                                                                                                                                           

In [12]: t = requests.get('https://9gag.com/v1/group-posts/group/gif/type/hot?')                                                                                                                                   

In [13]: t.json()
lsb_release -a:
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.6 LTS
Release:        16.04
Codename:       xenial

ipython:
Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

But when I do print(t.json()):

*** UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 16134: ordinal not in range(128)

The detail if I run t.json() everything goes right and ipython prints the conversion, but using print goes wrong.

*That looks like my terminal: -bash: warning: setlocale: LC_CTYPE: cannot change locale (pt_BR.UTF-8)

  • 1

    Vinicius, did you check this link? : https://stackoverflow.com/questions/57408252/unicodeencodeerror-ascii-codec-cant-encode-character-u-xbf-in-position-3

  • 1

    It shows up in my terminal: -bash: warning: setlocale: LC_CTYPE: cannot change locale (pt_BR.UTF-8)

  • 1

    Voce is sure u the projector is running with python 3.5, not with the server python2?

  • yeah, I made sure of it. it’s running on an env

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.