1👍
You can do like this
import urllib2
url = 'http://samples.openweathermap.org/data/2.5/weather?zip={0},us&appid=0b7f3cd153bc12d3accb83f9682bccbb'.format(zipcode) # if zipcode is defined
response = urllib2.urlopen(url)
response.read()
1👍
By Using API you mean sending GET, POST, PUT etc. requests to some server. For that you can use python’s requests
module. Like this:
### Installation
pip install requests
### Usage
import requests
url = 'http://samples.openweathermap.org/data/2.5/weather?zip={0},us&appid=0b7f3cd153bc12d3accb83f9682bccbb'.format(zipcode)
req = requests.get(url)
### if json response is coming
response = req.json()
### else
response = req.content
More information at Python Requests Documentation
- [Answered ]-Open text file stored as record in Django db
- [Answered ]-Django ORM: Get latest record for distinct field
Source:stackexchange.com