#!/usr/bin/env python # coding: utf-8 # In[ ]: ################################################################ ## ImportingData #2.2 ## Atul Singh ## www.datagenx.net ################################################################ # In[1]: # import import json # ### Reading json data # In[2]: with open("glossary.json") as json_file: jdata = json.load(json_file) # In[3]: # reading key value from json file for key in jdata.keys(): print(key," : ", jdata[key]) # In[5]: ## Reading widget.json file fh = open("widget.json") data = json.load(fh) for k in data.keys(): print(k," : ", data[k] ) # In[ ]: # In[ ]: # In[6]: # Import package import requests # Assign URL to variable: url url = 'https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=pizza' # Package the request, send the request and catch the response: r r = requests.get(url) # Decode the JSON data into a dictionary: json_data json_data = r.json() # Print the Wikipedia page extract pizza_extract = json_data['query']['pages']['24768']['extract'] print(pizza_extract) # In[7]: # Import requests package import requests # Assign URL to variable: url url = 'http://www.omdbapi.com/?t=social+network' # Package the request, send the request and catch the response: r r = requests.get(url) # Print the text of the response print(r.text) # In[ ]: # In[ ]: ############################################################ ## Atul Singh | www.datagenx.net | lnked.in/atulsingh ############################################################