python3: Read json file from url python3: Read json file from url json json

python3: Read json file from url


You were close:

import requestsimport jsonresponse = json.loads(requests.get("your_url").text)


Just use json and requests modules:

import requests, jsoncontent = requests.get("http://example.com")json = json.loads(content.content)


So you want to be able to reference specific values with inputting keys? If i think i know what you want to do, this should help you get started. You will need the libraries urlllib2, json, and bs4. just pip install them its easy.

import urllib2import jsonfrom bs4 import BeautifulSoupurl = urllib2.urlopen("https://www.govtrack.us/data/congress/113/votes/2013/s11/data.json")content = url.read()soup = BeautifulSoup(content, "html.parser")newDictionary=json.loads(str(soup))

I used a commonly used url to practice with.