Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8667235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:55:02+00:00 2026-06-12T17:55:02+00:00

I am using the requests library to query the Diffbot API to get contents

  • 0

I am using the requests library to query the Diffbot API to get contents of an article from a web page url. When I visit a request URL that I create in my browser, it returns a JSON object with the text in Unicode (right?) for example (I shortended the text somewhat):

{“icon”:”http://mexico.cnn.com/images/ico_mobile.jpg”,”text”:”CIUDAD
DE MÉXICO (CNNMéxico) \u2014 Kassandra Guazo Cano tiene 32 años, pero
este domingo participó por primera vez en una elección.\n\”No había
sacado mi (credencial del) IFE (Instituto Federal Electoral) porque al
hacer el trámite hay mucha mofa cuando ven que tu nombre no coincide
con tu y otros documentos de acuerdo con su nueva identidad.\nSánchez
dice que los solicitantes no son discriminados, pero la experiencia de
Kassanda es diferente: \”hay que pagar un licenciado, dos peritos
(entre ellos un endocrinólogo). Además, el juez dicta sentencia para
el cambio de nombre y si no es favorable tienes que esperar otros
cuatro años para volver a demandar al registro civil\”.\nAnte esta
situación, el Consejo para Prevenir y Eliminar la sculina, los
transgénero votan – México: Voto 2012 –
Nacional”,”url”:”http://mexico.cnn.com/nacional/2012/07/02/con-apariencia-de-mujer-e-identidad-masculina-los-transexuales-votan”,”xpath”:”/HTML[1]/BODY[1]/SECTION[5]/DIV[1]/ARTICLE[1]/DIV[1]/DIV[6]”}

When I use the python request library as follows:

def get_article(self, params={}):
  api_endpoint = 'http://www.diffbot.com/api/article'
  params.update({
    'token': self.dev_token,
    'format': self.output_format,
  })
  req = requests.get(api_endpoint, params=params)
  return json.loads(req.content)

It returns this (again note that I shortened the text somewhat):

{u’url’:
u’http://mexico.cnn.com/nacional/2012/07/02/con-apariencia-de-mujer-e-identidad-masculina-los-transexuales-votan’,
u’text’: u’CIUDAD DE M\xc9XICO (CNNM\xe9xico) \u2014 Kassandra Guazo
Cano tiene 32 a\xf1os, pero este domingo particip\xf3 por primera vez
en una elecci\xf3n.\n”No hab\xeda sacado mi (credencial del) IFE
(Instituto Federal Electoral) porque al hacOyuky Mart\xednez Col\xedn,
tambi\xe9n transg\xe9nero, y que estaba acompa\xf1ada de sus dos hijos
y su mam\xe1.\nAmbas trabajan como activistas en el Centro de Apoyo a
las Identidades Trans, A.C., donde participan en una campa\xf1a de
prevenci\xf3n de enfermedades sexuales.\n”Quisi\xe9ramos que no solo
nos vean como trabajadoras sexuales o estilistas, sino que luchamos
por nuestros derechos”, dice Kassandra mientras sonr\xede, sostiene su
credencial de elector y levanta su pulgar entintado.’, u’title’: u’Con
apariencia de mujer e identidad masculina, los transg\xe9nero votan –
M\xe9xico: Voto 2012 – Nacional’, u’xpath’:
u’/HTML[1]/BODY[1]/SECTION[5]/DIV[1]/ARTICLE[1]/DIV[1]/DIV[6]’,
u’icon’: u’http://mexico.cnn.com/images/ico_mobile.jpg’}

I don’t quite understand Unicode. How to make sure that what I get with requests is still Unicode?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:55:04+00:00Added an answer on June 12, 2026 at 5:55 pm

    You can use req.text instead of req.content to ensure that you get Unicode. This is described in:

    https://requests.readthedocs.io/en/latest/api/#requests.Response.text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using GAPI library (in PHP) for querying Google Analytics API. I request 2
How do I send GET requests using the Jersey Client API to a server
The current trend in web applications seems to be towards using GET requests for
I am using PHP's build in cURL library to make GET requests to the
I am using apache's common httpclient library. Is it possible to make HTTP request
I'm using requests (as adviced by Daniel Roseman) to post on a webform: url
I'm creating multiple asynchronous web requests using IObservables and reactive extensions. So this creates
Hi I'm having trouble posting a text file using the Python Requests Library (
I am using ASIHTTP library to send the requests.I send the login in synchronously
I am making several http requests to a particular host using python's urllib2 library.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.