Reputation: 11
How to integrate the JSON Web Services/Web Api with our python Program and Program should get configuration settings at run time from configuration file
import urllib.request
a_url = 'http://www.w3.org/2005/Atom'
data = urllib.request.urlopen(a_url).read()
print(data)
I have found this code,regarding my problem.Is this the right way to do? please help me out of this.
Upvotes: 1
Views: 44
Reputation: 7138
You can use requests
, no sane person uses urllib.
Install it:
$ pip install requests
Then use it like this:
import requests
a_url = 'http://www.w3.org/2005/Atom'
response = requests.get(a_url)
response.status_code # 200
response.text # html of the webpage
# response.json() # only if the url responds with json data, otherwise it will throw error
Upvotes: 2