内容简介:翻译自: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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Web Designer's Idea Book
Patrick Mcneil / How / 2008-10-6 / USD 25.00
The Web Designer's Idea Book includes more than 700 websites arranged thematically, so you can find inspiration for layout, color, style and more. Author Patrick McNeil has cataloged more than 5,000 s......一起来看看 《The Web Designer's Idea Book》 这本书的介绍吧!