python – 为什么要从Google App Engines导入urlfetch?

栏目: Python · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/1893012/why-import-urlfetch-from-google-app-engines
Here in Google App Engines

我得到的代码有助于通过URL获取任何网页的HTML代码:

from google.appengine.api import urlfetch
url = "http://www.google.com/"
result = urlfetch.fetch(url)
if result.status_code == 200:
doSomethingWithResult(result.content)

我不明白这里有一件事(事实上还有很多其他事情)为什么在这段代码中建议从google.appengine.api导入urlfecth? Python没有自己的命令吗?

google.appengine.api是一个包含Google版本的urlfetch类的库.引用 from the manual

The URL Fetch service uses Google’s  network infrastructure for efficiency  and scaling purposes.

Python在其标准库中也有url检索类,但那些无法使用App Engine中可用的基础结构.

简而言之,google.appengine.api urlfetch功能更强大,但是你也没有阻止使用Pythons自己的urllib,这也在我上面链接的手册页中有所描述.

翻译自:https://stackoverflow.com/questions/1893012/why-import-urlfetch-from-google-app-engines


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Test Driven Development

Test Driven Development

Kent Beck / Addison-Wesley Professional / 2002-11-18 / USD 49.99

Quite simply, test-driven development is meant to eliminate fear in application development. While some fear is healthy (often viewed as a conscience that tells programmers to "be careful!"), the auth......一起来看看 《Test Driven Development》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换