Fetching an external URL
Python includes the urllib
library for fetching urls:
import urllib
page = urllib.urlopen('http://www.web2py.com').read()
This is often fine, but the urllib
module does not work on the Google App Engine. Google provides a different API for downloading URLs that works on GAE only. In order to make your code portable, web2py includes a fetch
function that works on GAE as well as other Python installations:
from gluon.tools import fetch
page = fetch('http://www.web2py.com')