从App Engine发送HTTP请求 [英] Sending HTTP requests from App Engine
问题描述
是否可以从我的AppEngine应用程序发送HTTP请求?我需要提出一些请求,并从其他网站提取一些数据。 是的。更多信息: http://code.google.com/appengine/ docs / python / urlfetch / overview.html
您可以使用Python标准的
库urllib,urllib2或httplib
发出HTTP请求。在
App Engine中运行时,这些库使用App Engine的URL
fetch服务执行
HTTP请求,该服务在Google的
可扩展HTTP请求基础架构上运行。
下面是一个例子:
import urllib
from xml.dom import minidom
from google.appengine.api import urlfetch
$ b 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)
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.
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)
这篇关于从App Engine发送HTTP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!