python cal url code example
Example 1: python open a url
import webbrowser
webbrowser.open('http://example.com') # Go to example.com
Example 2: urllib.request headers
try:
from urllib.request import Request, urlopen # Python 3
except ImportError:
from urllib2 import Request, urlopen # Python 2
req = Request('http://api.company.com/items/details?country=US&language=en')
req.add_header('apikey', 'xxx')
content = urlopen(req).read()
print(content)