views:

88

answers:

1

Is it possible to send HTTP requests from my AppEngine application? I need to make some requests and pull some data from the other sites.

+3  A: 

Yes. More info here: http://code.google.com/appengine/docs/python/urlfetch/overview.html

You can use the Python standard libraries urllib, urllib2 or httplib to make HTTP requests. When running in App Engine, these libraries perform HTTP requests using App Engine's URL fetch service, which runs on Google's scalable HTTP request infrastructure.

Here's an example:

import urllib
from xml.dom import minidom
from google.appengine.api import urlfetch

params = urllib.urlencode({'p': loc_param, 'u': units,})
full_uri = '?'.join([url, params,])

result = urlfetch.fetch(full_uri)
if result.status_code == 200:
    return minidom.parseString(result.content)
Adam Bernier
Thank you Adam.
pocoa
You can also use urllib and urllib2 directly; they're patched to use the urlfetch service for you.
Wooble