2
是否可以从我的AppEngine应用程序发送HTTP请求?我需要提出一些请求并从其他网站提取一些数据。从App Engine发送HTTP请求
是否可以从我的AppEngine应用程序发送HTTP请求?我需要提出一些请求并从其他网站提取一些数据。从App Engine发送HTTP请求
是的。这里更多的信息:http://code.google.com/appengine/docs/python/urlfetch/overview.html
您可以使用Python标准 库的urllib,urllib2的或httplib的 使HTTP请求。在 App Engine中运行时,这些库使用App Engine的URL 提取服务执行 HTTP请求,该服务在Google的 可伸缩HTTP请求基础结构上运行。
下面是一个例子:
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)
谢谢亚当。 – pocoa 2010-05-14 14:20:18
您也可以直接使用urllib和urllib2;他们修补为您使用urlfetch服务。 – geoffspear 2010-05-14 17:10:31