mashape python unirest library

899 views Asked by At

I'm trying to use unirest library to run API to dmoz. this is my code:

=========================================================================

import unirest

response = unirest.get("https://enclout-dmoz.p.mashape.com/show.json?auth_token=something&url=www.nike.com",
  headers={
    "X-Mashape-Key": "another_code"
      }
    )
html= response.body()
print html 

but I get an error message: Typeerror the object 'dict' is not callable.

2

There are 2 answers

2
Milind Dumbare On BEST ANSWER

Access the dict without brackets

 html = response.body
 print html
0
gvir On

Yes response is a dictionary. It has following members

code, headers, body and raw_body, you can get information as below

# print response
print "code:"+ str(response.code)
print "******************"
print "headers:"+ str(response.headers)
print "******************"
print "body:"+ str(response.body)
print "******************"
print "raw_body:"+ str(response.raw_body)

Check out the post http://stackandqueue.com/?p=57 which explains in detail how to make calls using unirest