Python urllib2: Receive JSON response from url

后端 未结 10 2035
轮回少年
轮回少年 2020-11-29 17:22

I am trying to GET a URL using Python and the response is JSON. However, when I run

import urllib2
response = urllib2.urlopen(\'https://api.instagram.com/v1/         


        
10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 18:11

    you can also get json by using requests as below:

    import requests
    
    r = requests.get('http://yoursite.com/your-json-pfile.json')
    json_response = r.json()
    

提交回复
热议问题