Python urllib2: Receive JSON response from url -


i trying url using python , response json. however, when run

import urllib2 response = urllib2.urlopen('https://api.instagram.com/v1/tags/pizza/media/xxxxxx') html=response.read() print html 

the html of type str , expecting json. there way can capture response json or python dictionary instead of str.

if url returning valid json-encoded data, use json library decode that:

import urllib2 import json  response = urllib2.urlopen('https://api.instagram.com/v1/tags/pizza/media/xxxxxx') data = json.load(response)    print data 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -