The following code works in the Python interactive shell:
import urllib2 result = urllib2.urlopen("http://www.google.com/")
and gives a result of 200.
If I ran the same code in an AppEngine application that works locally with a development server, it did not execute the following error:
URLError: <urlopen error An error occured while connecting to the server: Unable to fetch URL: http:
I tried using the urlfetch library urlfetch :
from google.appengine.api import urlfetch result = urlfetch.fetch("http://www.google.com")
and this also fails (which makes sense since I believe urllib2 inside AppEngine calls urlfetch internally?)
I can access the url from my local machine - so what happens?
UPDATE: corresponding stack trace:
File "c:\dev\repos\stackoverflow\main.py", line 40, in get_latest_comments result = urlfetch.fetch("http://www.google.com") File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py", line 266, in fetch return rpc.get_result() File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 604, in get_result return self.__get_result_hook(self) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py", line 397, in _get_fetch_result raise DownloadError("Unable to fetch URL: " + url + error_detail) DownloadError: Unable to fetch URL: http:
source share