2

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.

4

2 回答 2

1

访问不带括号的字典

 html = response.body
 print html
于 2014-11-27T08:08:52.050 回答
0

是的,响应是一本字典。它有以下成员

code, headers, body 和 raw_body,你可以得到如下信息

# 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)

查看帖子http://stackandqueue.com/?p=57详细解释了如何使用 unirest 拨打电话

于 2016-01-19T17:06:57.120 回答