Wednesday, 15 February 2012

python - Cannot connect to REST Api using httplib2 -



python - Cannot connect to REST Api using httplib2 -

i'm trying execute little code below , print json object retrived restapi

import httplib2 h = httplib2.http(".cache") (resp_headers, content) = h.request("http://content.gaurdianapis.com/search?q=obama&format=json") print content

but i'm giving below error :-

traceback (most recent phone call last): file "test.py", line 10, in <module> (resp_headers, content) = h.request("http://content.gaurdianapis.com/search?q=obama&format=json") file "/usr/lib/python2.6/site-packages/httplib2/__init__.py", line 1593, in request (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey) file "/usr/lib/python2.6/site-packages/httplib2/__init__.py", line 1335, in _request (response, content) = self._conn_request(conn, request_uri, method, body, headers) file "/usr/lib/python2.6/site-packages/httplib2/__init__.py", line 1263, in _conn_request raise servernotfounderror("unable find server @ %s" % conn.host) httplib2.servernotfounderror: unable find server @ content.gaurdianapis.com

can help me out here ? if i'm attempting browser getting opened , going wrong ?

python python-2.7

No comments:

Post a Comment